diff --git a/README.md b/README.md index 7c41cc21..0a0d8163 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ $ npm install -g codify $ codify COMMAND running command... $ codify (--version) -codify/0.7.0 darwin-arm64 node-v20.15.1 +codify/0.7.1 darwin-arm64 node-v20.15.1 $ codify --help [COMMAND] USAGE $ codify COMMAND @@ -74,7 +74,7 @@ EXAMPLES $ codify apply -S ``` -_See code: [src/commands/apply.ts](https://github.com/kevinwang5658/codify/blob/v0.7.0/src/commands/apply.ts)_ +_See code: [src/commands/apply.ts](https://github.com/kevinwang5658/codify/blob/v0.7.1/src/commands/apply.ts)_ ## `codify destroy` @@ -113,7 +113,7 @@ EXAMPLES $ codify destroy ``` -_See code: [src/commands/destroy.ts](https://github.com/kevinwang5658/codify/blob/v0.7.0/src/commands/destroy.ts)_ +_See code: [src/commands/destroy.ts](https://github.com/kevinwang5658/codify/blob/v0.7.1/src/commands/destroy.ts)_ ## `codify help [COMMAND]` @@ -189,7 +189,7 @@ EXAMPLES $ codify import \* ``` -_See code: [src/commands/import.ts](https://github.com/kevinwang5658/codify/blob/v0.7.0/src/commands/import.ts)_ +_See code: [src/commands/import.ts](https://github.com/kevinwang5658/codify/blob/v0.7.1/src/commands/import.ts)_ ## `codify init` @@ -217,7 +217,7 @@ EXAMPLES $ codify init ``` -_See code: [src/commands/init.ts](https://github.com/kevinwang5658/codify/blob/v0.7.0/src/commands/init.ts)_ +_See code: [src/commands/init.ts](https://github.com/kevinwang5658/codify/blob/v0.7.1/src/commands/init.ts)_ ## `codify plan` @@ -254,7 +254,7 @@ EXAMPLES $ codify plan -p ../ ``` -_See code: [src/commands/plan.ts](https://github.com/kevinwang5658/codify/blob/v0.7.0/src/commands/plan.ts)_ +_See code: [src/commands/plan.ts](https://github.com/kevinwang5658/codify/blob/v0.7.1/src/commands/plan.ts)_ ## `codify update [CHANNEL]` diff --git a/codify.json b/codify.json index 36966f05..3da40469 100644 --- a/codify.json +++ b/codify.json @@ -5,213 +5,9 @@ "default": "../codify-homebrew-plugin/src/index.ts" } }, - { "type": "virtualenv" }, - { "type": "virtualenv-project", "dest": ".venv12", "cwd": "~/Projects/python-temp2", "automaticallyInstallRequirementsTxt": true }, - { "type": "pnpm", "version": "9.15.5", "globalEnvNodeVersion": "20.15" }, - { "type": "path", "path": "$HOME/.bun/bin"}, - { - "type": "path", - "paths": [ - "$PYENV_ROOT/bin", - "$BUN_INSTALL/bin", - "$DENO_INSTALL/bin", - "~/.jenv/bin", - "~/a/random/path", - "$NVM_DIR/.bin/2", - "$NVM_DIR/.bin/3" - ], - "declarationsOnly": true, - "name": "1" - }, - { - "type": "homebrew", - "taps": [ - "cirruslabs/cli", - "hashicorp/tap", - "homebrew/bundle", - "homebrew/services" - ], - "casks": [ - "android-commandlinetools", - "android-studio", - "mitmproxy" - ], - "formulae": [ - "ack", - "asciinema", - "cirrus", - "expect", - "git-lfs", - "groff", - "hyperfine", - "jenv", - "jq", - "mas", - "openjdk@11", - "openjdk@17", - "openjdk@21", - "packer", - "pgcli", - "postgresql@14", - "sshpass", - "tart", - "xz", - "zstd", - "f1bonacc1/tap/process-compose" - ] - }, - { "version":"1.10.5","type":"terraform" }, - { "type": "alias", "alias": "gcdsdd", "value": "git clone" }, - { - "type": "ssh-config", - "hosts": [ - { - "Host": "192.168.64.94", - "HostName": "192.168.64.94", - "User": "admin" - }, - { - "Host": "192.168.2.48", - "HostName": "192.168.2.48", - "User": "pi" - }, - { - "Host": "*", - "AddKeysToAgent": true, - "IdentityFile": "~/.ssh/id_ed25519" - }, - { - "Host": "ec2", - "HostName": "54.82.78.202", - "User": "ec2-user", - "IdentityFile": "~/.ssh/ed25519" - }, - { - "Host": "ec2-2", - "HostName": "35.153.180.154", - "User": "ec2-user", - "IdentityFile": "~/.ssh/ed25519" - } - ] - }, - { - "type": "ssh-key", - "fileName": "id_ed25519", - "passphrase": "", - "keyType": "ed25519" - }, { "type": "alias", - "alias": "gc", - "value": "git commit -v" - }, - { - "type": "pgcli" - }, - { - "type": "file", - "contents": "[\n\t{\n \"type\": \"homebrew\",\n \"taps\": [\n \"cirruslabs/cli\",\n \"hashicorp/tap\",\n \"homebrew/services\"\n ],\n \"formulae\": [\n \"asciinema\",\n \"cairo\",\n \"cirrus\",\n \"expect\",\n \"glib\",\n \"hyperfine\",\n \"icu4c\",\n \"jq\",\n \"mas\",\n \"packer\",\n \"sshpass\",\n \"tart\"\n ],\n \"casks\": [\n \t\"firefox\",\n \t\"notion\",\n \t\"sublime-text\",\n \t\"webstorm\",\n \t\"mac-mouse-fix\",\n \t\"wins\",\n \t\"warp\",\n \t\"hammerspoon\",\n \t\"rectangle\",\n \t\"alt-tab\",\n \t\"betterdisplay\",\n \t\"daisydisk\",\n \t\"visual-studio-code\"\n ]\n },\n\n\t{ \"type\": \"nvm\", \"nodeVersions\": [\"20\"], \"global\": \"20\" },\n\t{ \"type\": \"pyenv\", \"pythonVersions\": [\"3.12\", \"3.11\"], \"global\": \"3.11\" },\n\n\t{\n \"type\": \"ssh-key\",\n \"fileName\": \"id_ed25519\",\n \"passphrase\": \"\",\n \"folder\": \"/Users/kevinwang/.ssh\",\n \"keyType\": \"ed25519\"\n },\n { \"type\": \"terraform\" },\n { \"type\": \"git-clone\", \"directory\": \"~/projects/codify\", \"repository\": \"git@github.com:kevinwang5658/codify.git\" },\n { \"type\": \"git-clone\", \"directory\": \"~/projects/codify-web\", \"repository\": \"git@github.com:kevinwang5658/codify-web.git\" },\n\t{ \"type\": \"git-clone\", \"directory\": \"~/projects/codify-homebrew-plugin\", \"repository\": \"git@github.com:kevinwang5658/codify-homebrew-plugin.git\" },\n { \"type\": \"git-clone\", \"directory\": \"~/projects/codify-infrastructure\", \"repository\": \"git@github.com:kevinwang5658/codify-infrastructure.git\" },\n { \"type\": \"git-clone\", \"directory\": \"~/projects/codify-docs\", \"repository\": \"git@github.com:kevinwang5658/codify-docs.git\" },\n { \"type\": \"git-clone\", \"directory\": \"~/projects/codify-ink-form\", \"repository\": \"git@github.com:kevinwang5658/codify-ink-form.git\" },\n\n\n { \"type\": \"action\", \"condition\": \"[ -d node_modules ]\", \"action\": \"npm install\", \"cwd\": \"~/projects/codify\", \"dependsOn\": [\"git-clone.0\", \"nvm\"]},\n { \"type\": \"action\", \"condition\": \"[ -d node_modules ]\", \"action\": \"npm install\", \"cwd\": \"~/projects/codify-web\", \"dependsOn\": [\"git-clone.1\", \"nvm\"]},\n { \"type\": \"action\", \"condition\": \"[ -d node_modules ]\", \"action\": \"npm install\", \"cwd\": \"~/projects/codify-homebrew-plugin\", \"dependsOn\": [\"git-clone.2\", \"nvm\"]},\n { \"type\": \"action\", \"condition\": \"[ -d node_modules ]\", \"action\": \"npm install\", \"cwd\": \"~/projects/codify-docs\", \"dependsOn\": [\"git-clone.4\", \"nvm\"]},\n { \"type\": \"action\", \"condition\": \"[ -d node_modules ]\", \"action\": \"npm install\", \"cwd\": \"~/projects/codify-ink-form\", \"dependsOn\": [\"git-clone.5\", \"nvm\"]}\n]", - "path": "~/codify.json" - }, - { - "type": "aws-cli" - }, - { - "type": "git-repository", - "directory": "~/Projects/codify-homebrew-plugin", - "repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git" - }, - { - "type": "vscode" - }, - { - "type": "git-repository", - "directory": "~/Projects/codify-plugin-lib", - "repository": "git@github.com:kevinwang5658/codify-plugin-lib.git" - }, - { - "type": "git-repository", - "directory": "~/Projects/codify", - "repository": "git@github.com:kevinwang5658/codify.git" - }, - { - "type": "wait-github-ssh-key" - }, - { - "type": "git-lfs" - }, - { - "type": "pyenv", - "global": "3.11", - "pythonVersions": [ - "3.9.19", - "3.10.14", - "3.11.8", - "3.12.2" - ] - }, - { - "type": "git", - "email": "kevinwang5658@gmail.com", - "username": "kevinwang" - }, - { - "type": "android-studio", - "version": "2023.3.1.20" - }, - { - "type": "ssh-add", - "path": "~/.ssh/id_ed25519" - }, - { - "type": "jenv", - "add": [ - "11", - "17", - "21" - ], - "global": "17" - }, - { - "type": "aws-profile", - "awsAccessKeyId": "AKIATCKATKL55TT5UZ7P", - "awsSecretAccessKey": "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", - "profile": "codify", - "region": "us-east-1" - }, - { - "type": "git-repository", - "directory": "~/Projects/codify-homebrew-plugin", - "repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git" - }, - { - "type": "git-repository", - "directory": "~/Projects/codify-homebrew-plugin", - "repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git" - }, - { - "type": "git-repository", - "directory": "~/Projects/codify-homebrew-plugin", - "repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git" - }, - { - "type": "git-repository", - "directory": "~/Projects/codify-homebrew-plugin", - "repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git" - }, - { - "type": "git-repository", - "directory": "~/Projects/codify-homebrew-plugin", - "repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git" - }, - { - "type": "git-repository", - "directory": "~/Projects/codify-homebrew-plugin", - "repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git" - }, - { - "type": "git-repository", - "directory": "~/Projects/codify-homebrew-plugin", - "repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git" + "alias": "la", + "value": "ls" } ] diff --git a/package.json b/package.json index 2f900ebf..f668e63e 100644 --- a/package.json +++ b/package.json @@ -123,7 +123,7 @@ "start:dev": "./bin/dev.js", "start:vm": "npm run build && npm run pack:macos && npm run start:vm" }, - "version": "0.7.0", + "version": "0.7.1", "bugs": "https://github.com/kevinwang5658/codify/issues", "keywords": [ "oclif" diff --git a/src/commands/apply.ts b/src/commands/apply.ts index c95b0008..9e9b73b0 100644 --- a/src/commands/apply.ts +++ b/src/commands/apply.ts @@ -44,6 +44,7 @@ For more information, visit: https://docs.codifycli.com/commands/apply await ApplyOrchestrator.run({ path: flags.path, + verbosityLevel: flags.debug ? 3 : 0, // secure: flags.secure, }, this.reporter); diff --git a/src/commands/destroy.ts b/src/commands/destroy.ts index 96c901c2..29c02c92 100644 --- a/src/commands/destroy.ts +++ b/src/commands/destroy.ts @@ -47,6 +47,7 @@ For more information, visit: https://docs.codifycli.com/commands/destory` } await DestroyOrchestrator.run({ + verbosityLevel: flags.debug ? 3 : 0, typeIds: args, path: flags.path, }, this.reporter) diff --git a/src/commands/import.ts b/src/commands/import.ts index 66097dc9..33578c85 100644 --- a/src/commands/import.ts +++ b/src/commands/import.ts @@ -61,6 +61,7 @@ For more information, visit: https://docs.codifycli.com/commands/import` const cleanedArgs = await this.cleanupZshStarExpansion(args); await ImportOrchestrator.run({ + verbosityLevel: flags.debug ? 3 : 0, typeIds: cleanedArgs, path: resolvedPath, secureMode: flags.secure, diff --git a/src/commands/init.ts b/src/commands/init.ts index bde0634d..2d95fd7a 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -25,6 +25,10 @@ For more information, visit: https://docs.codifycli.com/commands/init` ] public async run(): Promise { - await InitializeOrchestrator.run(this.reporter); + const { flags } = await this.parse(Init) + + await InitializeOrchestrator.run({ + verbosityLevel: flags.debug ? 3 : 0, + },this.reporter); } } diff --git a/src/commands/plan.ts b/src/commands/plan.ts index 3e941b3b..f985d270 100644 --- a/src/commands/plan.ts +++ b/src/commands/plan.ts @@ -30,6 +30,7 @@ For more information, visit: https://docs.codifycli.com/commands/plan` const { flags } = await this.parse(Plan) await PlanOrchestrator.run({ + verbosityLevel: flags.debug ? 3 : 0, path: flags.path, secureMode: flags.secure, }, this.reporter); diff --git a/src/common/initialize-plugins.ts b/src/common/initialize-plugins.ts index 406b6d9c..4c2d6a1f 100644 --- a/src/common/initialize-plugins.ts +++ b/src/common/initialize-plugins.ts @@ -11,6 +11,7 @@ import { Reporter } from '../ui/reporters/reporter.js'; export interface InitializeArgs { path?: string; secure?: boolean; + verbosityLevel?: number; transformProject?: (project: Project) => Project | Promise; allowEmptyProject?: boolean; } @@ -37,7 +38,7 @@ export class PluginInitOrchestrator { ctx.subprocessStarted(SubProcessName.INITIALIZE_PLUGINS) const pluginManager = new PluginManager(); - const typeIdsToDependenciesMap = await pluginManager.initialize(project, args.secure); + const typeIdsToDependenciesMap = await pluginManager.initialize(project, args.secure, args.verbosityLevel); ctx.subprocessFinished(SubProcessName.INITIALIZE_PLUGINS) return { typeIdsToDependenciesMap, pluginManager, project }; diff --git a/src/orchestrators/apply.ts b/src/orchestrators/apply.ts index cda14281..f02af8b3 100644 --- a/src/orchestrators/apply.ts +++ b/src/orchestrators/apply.ts @@ -6,6 +6,7 @@ import { PlanOrchestrator } from './plan.js'; export interface ApplyArgs { path?: string; secure?: boolean; + verbosityLevel?: number; } export const ApplyOrchestrator = { diff --git a/src/orchestrators/destroy.ts b/src/orchestrators/destroy.ts index 1e10f57c..a00a1212 100644 --- a/src/orchestrators/destroy.ts +++ b/src/orchestrators/destroy.ts @@ -12,6 +12,7 @@ export interface DestroyArgs { typeIds: string[]; path?: string; secureMode?: boolean; + verbosityLevel?: number; } export class DestroyOrchestrator { diff --git a/src/orchestrators/import.ts b/src/orchestrators/import.ts index ac2f0344..21eff605 100644 --- a/src/orchestrators/import.ts +++ b/src/orchestrators/import.ts @@ -20,6 +20,7 @@ export interface ImportArgs { typeIds?: string[]; path: string; secureMode?: boolean; + verbosityLevel?: number; } export class ImportOrchestrator { diff --git a/src/orchestrators/init.ts b/src/orchestrators/init.ts index 86aed7d0..34db10e4 100644 --- a/src/orchestrators/init.ts +++ b/src/orchestrators/init.ts @@ -8,16 +8,20 @@ import { Reporter } from '../ui/reporters/reporter.js'; import { FileUtils } from '../utils/file.js'; import { resolvePathWithVariables, untildify } from '../utils/index.js'; +export interface InitArgs { + verbosityLevel?: number; +} + export const InitializeOrchestrator = { - async run(reporter: Reporter) { + async run(args: InitArgs, reporter: Reporter) { await reporter.displayInitBanner() ctx.processStarted(ProcessName.INIT) await reporter.displayProgress(); - const { pluginManager, typeIdsToDependenciesMap } = await PluginInitOrchestrator.run({}, reporter); + const { pluginManager, typeIdsToDependenciesMap } = await PluginInitOrchestrator.run(args, reporter); ctx.subprocessStarted(SubProcessName.IMPORT_RESOURCE) const importResults = await Promise.all([...typeIdsToDependenciesMap.keys()].map(async (typeId) => { diff --git a/src/orchestrators/plan.ts b/src/orchestrators/plan.ts index bcafa143..f4183ff3 100644 --- a/src/orchestrators/plan.ts +++ b/src/orchestrators/plan.ts @@ -10,6 +10,7 @@ import { ValidateOrchestrator } from './validate.js'; export interface PlanArgs { path?: string; secureMode?: boolean; + verbosityLevel?: number; } export interface PlanOrchestratorResponse { diff --git a/src/orchestrators/validate.ts b/src/orchestrators/validate.ts index b49d564b..c500ac2b 100644 --- a/src/orchestrators/validate.ts +++ b/src/orchestrators/validate.ts @@ -5,6 +5,7 @@ import { InitializationResult, PluginInitOrchestrator } from '../common/initiali export interface ValidateArgs { existing?: InitializationResult; path?: string; + verbosityLevel?: number; } export const ValidateOrchestrator = { diff --git a/src/plugins/plugin-manager.ts b/src/plugins/plugin-manager.ts index cb69ef79..9889183d 100644 --- a/src/plugins/plugin-manager.ts +++ b/src/plugins/plugin-manager.ts @@ -28,7 +28,7 @@ export class PluginManager { private resourceToPluginMapping = new Map() private pluginToResourceMapping = new Map() - async initialize(project: Project | null, secureMode = false): Promise { + async initialize(project: Project | null, secureMode = false, verbosityLevel = 0): Promise { const plugins = await this.resolvePlugins(project); for (const plugin of plugins) { @@ -37,7 +37,7 @@ export class PluginManager { this.registerKillListeners(plugins) - const dependencyMap = await this.initializePlugins(plugins, secureMode); + const dependencyMap = await this.initializePlugins(plugins, secureMode, verbosityLevel); return dependencyMap; } @@ -158,10 +158,10 @@ export class PluginManager { return PluginResolver.resolveAll(pluginDefinitions); } - private async initializePlugins(plugins: Plugin[], secureMode: boolean): Promise> { + private async initializePlugins(plugins: Plugin[], secureMode: boolean, verbosityLevel: number): Promise> { const responses = await Promise.all( plugins.map(async (p) => { - const initializeResult = await p.initialize(secureMode); + const initializeResult = await p.initialize(secureMode, verbosityLevel); return [p.name, initializeResult.resourceDefinitions] as const }) ); diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index eee0a56a..c6521c45 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -29,7 +29,7 @@ const importResponseValidator = ajv.compile(ImportResponseDataSchema); const planResponseValidator = ajv.compile(PlanResponseDataSchema); export interface IPlugin { - initialize(secureMode: boolean): Promise; + initialize(secureMode: boolean, verbosityLevel: number): Promise; validate(configs: ResourceConfig[]): Promise; getResourceInfo(type: string): Promise; match(resource: ResourceConfig, array: ResourceConfig[]): Promise; @@ -53,10 +53,10 @@ export class Plugin implements IPlugin { this.path = path; } - async initialize(secureMode: boolean): Promise { + async initialize(secureMode: boolean, verbosityLevel = 0): Promise { this.process = await PluginProcess.start(this.path, this.name, secureMode); - const initializeResponse = await this.process.sendMessageForResult('initialize', {}); + const initializeResponse = await this.process.sendMessageForResult('initialize', { verbosityLevel }); if (!this.validateInitializeResponse(initializeResponse.data)) { throw new Error(`Invalid initialize response from plugin: ${this.name}`);