@azrico/azcli 1.1.53 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +65 -0
  2. package/dist/cli/create-cli.js +40 -0
  3. package/dist/cli/create-cli.js.map +1 -0
  4. package/dist/cli/index.js +20 -0
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/cli/options.js +17 -0
  7. package/dist/cli/options.js.map +1 -0
  8. package/dist/core/files.js +82 -0
  9. package/dist/core/files.js.map +1 -0
  10. package/dist/core/json.js +16 -0
  11. package/dist/core/json.js.map +1 -0
  12. package/dist/core/logger.js +26 -0
  13. package/dist/core/logger.js.map +1 -0
  14. package/dist/core/process.js +120 -0
  15. package/dist/core/process.js.map +1 -0
  16. package/dist/core/project-type.js +41 -0
  17. package/dist/core/project-type.js.map +1 -0
  18. package/dist/core/strings.js +20 -0
  19. package/dist/core/strings.js.map +1 -0
  20. package/dist/features/build/build.js +46 -0
  21. package/dist/features/build/build.js.map +1 -0
  22. package/dist/features/build/command.js +17 -0
  23. package/dist/features/build/command.js.map +1 -0
  24. package/dist/features/build/wordpress.js +135 -0
  25. package/dist/features/build/wordpress.js.map +1 -0
  26. package/dist/features/clean/clean.js +27 -0
  27. package/dist/features/clean/clean.js.map +1 -0
  28. package/dist/features/clean/command.js +13 -0
  29. package/dist/features/clean/command.js.map +1 -0
  30. package/dist/features/optimize-transcripts/agent-runner.js +40 -0
  31. package/dist/features/optimize-transcripts/agent-runner.js.map +1 -0
  32. package/dist/features/optimize-transcripts/command.js +24 -0
  33. package/dist/features/optimize-transcripts/command.js.map +1 -0
  34. package/dist/features/optimize-transcripts/optimize.js +72 -0
  35. package/dist/features/optimize-transcripts/optimize.js.map +1 -0
  36. package/dist/features/optimize-transcripts/prompts.js +39 -0
  37. package/dist/features/optimize-transcripts/prompts.js.map +1 -0
  38. package/dist/features/optimize-transcripts/redact.js +57 -0
  39. package/dist/features/optimize-transcripts/redact.js.map +1 -0
  40. package/dist/features/optimize-transcripts/secret-remover.js +85 -0
  41. package/dist/features/optimize-transcripts/secret-remover.js.map +1 -0
  42. package/dist/features/package/command.js +13 -0
  43. package/dist/features/package/command.js.map +1 -0
  44. package/dist/features/package/packager.js +132 -0
  45. package/dist/features/package/packager.js.map +1 -0
  46. package/dist/features/publish/command.js +13 -0
  47. package/dist/features/publish/command.js.map +1 -0
  48. package/dist/features/publish/publish.js +29 -0
  49. package/dist/features/publish/publish.js.map +1 -0
  50. package/dist/features/transcripts/command.js +27 -0
  51. package/dist/features/transcripts/command.js.map +1 -0
  52. package/dist/features/transcripts/extract.js +148 -0
  53. package/dist/features/transcripts/extract.js.map +1 -0
  54. package/dist/features/transcripts/jsonl.js +100 -0
  55. package/dist/features/transcripts/jsonl.js.map +1 -0
  56. package/dist/features/transcripts/options.js +53 -0
  57. package/dist/features/transcripts/options.js.map +1 -0
  58. package/dist/features/transcripts/render-markdown.js +105 -0
  59. package/dist/features/transcripts/render-markdown.js.map +1 -0
  60. package/dist/features/transcripts/sources/claude.js +150 -0
  61. package/dist/features/transcripts/sources/claude.js.map +1 -0
  62. package/dist/features/transcripts/sources/codex.js +171 -0
  63. package/dist/features/transcripts/sources/codex.js.map +1 -0
  64. package/dist/features/transcripts/types.js +5 -0
  65. package/dist/features/transcripts/types.js.map +1 -0
  66. package/dist/features/update/command.js +16 -0
  67. package/dist/features/update/command.js.map +1 -0
  68. package/dist/features/update/composer.js +35 -0
  69. package/dist/features/update/composer.js.map +1 -0
  70. package/dist/features/update/filter-options.js +23 -0
  71. package/dist/features/update/filter-options.js.map +1 -0
  72. package/dist/features/update/update.js +28 -0
  73. package/dist/features/update/update.js.map +1 -0
  74. package/dist/features/update/yarn.js +30 -0
  75. package/dist/features/update/yarn.js.map +1 -0
  76. package/dist/features/verify-changes/changed-files.js +36 -0
  77. package/dist/features/verify-changes/changed-files.js.map +1 -0
  78. package/dist/features/verify-changes/command.js +25 -0
  79. package/dist/features/verify-changes/command.js.map +1 -0
  80. package/dist/features/verify-changes/config.js +59 -0
  81. package/dist/features/verify-changes/config.js.map +1 -0
  82. package/dist/features/verify-changes/report.js +30 -0
  83. package/dist/features/verify-changes/report.js.map +1 -0
  84. package/dist/features/verify-changes/select.js +39 -0
  85. package/dist/features/verify-changes/select.js.map +1 -0
  86. package/dist/features/verify-changes/verify.js +54 -0
  87. package/dist/features/verify-changes/verify.js.map +1 -0
  88. package/dist/features/yarn/commands.js +18 -0
  89. package/dist/features/yarn/commands.js.map +1 -0
  90. package/package.json +41 -55
  91. package/dist/cli.js +0 -2
  92. package/dist/libs/builder/build_docker.js +0 -1
  93. package/dist/libs/builder/build_python.js +0 -10
  94. package/dist/libs/builder/build_wp.js +0 -1
  95. package/dist/libs/builder/build_yarn.js +0 -1
  96. package/dist/libs/builder/index.js +0 -1
  97. package/dist/libs/cleaner/clean_composer.js +0 -1
  98. package/dist/libs/cleaner/cleanbuild.js +0 -1
  99. package/dist/libs/cleaner/cleannext.js +0 -1
  100. package/dist/libs/cleaner/cleannode.js +0 -1
  101. package/dist/libs/cleaner/index.js +0 -1
  102. package/dist/libs/commons/filehandler.js +0 -5
  103. package/dist/libs/commons/helper_exec.js +0 -3
  104. package/dist/libs/commons/helper_interface.js +0 -10
  105. package/dist/libs/commons/helper_string.js +0 -1
  106. package/dist/libs/commons/index.js +0 -1
  107. package/dist/libs/integ/index.js +0 -1
  108. package/dist/libs/integ/integ_readme.js +0 -1
  109. package/dist/libs/packager/index.js +0 -1
  110. package/dist/libs/packager/packager.js +0 -16
  111. package/dist/libs/publisher/index.js +0 -1
  112. package/dist/libs/publisher/publish_python.js +0 -5
  113. package/dist/libs/up/filterOptionsByAcceptable.js +0 -5
  114. package/dist/libs/up/index.js +0 -1
  115. package/dist/libs/up/update_composer.js +0 -1
  116. package/dist/libs/up/update_py.js +0 -1
  117. package/dist/libs/up/update_yarn.js +0 -2
  118. package/dist/libs/yarnhelp/index.js +0 -1
  119. package/dist/libs/yarnhelp/yarnb.js +0 -1
  120. package/dist/libs/yarnhelp/yarni.js +0 -1
  121. package/dist/libs/yarnhelp/yarnt.js +0 -1
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # az-cli
2
+
3
+ Helpers for building, cleaning, updating, and publishing projects, plus exporting and analysing AI session transcripts.
4
+
5
+ Requires Node.js 20 or newer. Yarn 4.6.0 is pinned in `package.json` and included in `.yarn/releases`.
6
+
7
+ ```sh
8
+ node .yarn/releases/yarn-4.6.0.cjs install --immutable
9
+ node .yarn/releases/yarn-4.6.0.cjs typecheck
10
+ node .yarn/releases/yarn-4.6.0.cjs test
11
+ node .yarn/releases/yarn-4.6.0.cjs build
12
+ node dist/cli/index.js --help
13
+ ```
14
+
15
+ With Yarn available on PATH, the equivalent commands are `yarn install --immutable`, `yarn typecheck`, `yarn test`, and `yarn build`.
16
+
17
+ `yarn build-dev` compiles the CLI and copies optional assets from `temp/` into `dist/`. `yarn start` watches source and asset changes. Builds use TypeScript directly and preserve source maps.
18
+
19
+ ## Commands
20
+
21
+ | Command | Behavior |
22
+ | --- | --- |
23
+ | `build [mode]` | Build an inferred project, or select `php`, `yarn`, `python`, or `docker`. Docker builds also start Compose services. |
24
+ | `clean build` | Remove `build/` and `dist/` in the selected project. |
25
+ | `clean all` | Also remove dependencies, caches, and lockfiles. |
26
+ | `up [target..]` | Update dependencies; Yarn targets may be omitted or repeated. |
27
+ | `publish` | Publish a Yarn or Python package. Yarn packages are built first. |
28
+ | `package prepare` | Generate the workspace's core package before building. |
29
+ | `package finalize` | Generate publishable manifests in `dist/`, `build/`, or `temp/`. |
30
+ | `package publish` | Publish the prepared packages. |
31
+ | `package go` | Prepare, build, finalize, then publish; stop on the first failure. |
32
+ | `yarni`, `yarnb`, `yarnt` | Run Yarn install, build, or test. |
33
+ | `transcripts <claude\|codex>` | Export sessions to Markdown with an `index.json`. |
34
+ | `optimize-transcripts <claude\|codex>` | Prepare a transcript snapshot and run the selected analysis agent. |
35
+ | `verify-changes` | Run the checks from `.azcli/verify.json` that match files changed since the base ref. Reports `passed`, `failed`, or `not-run`; exits 1 on failure (`--strict` also on not-run). `--profile`, `--base`, `--json`. |
36
+
37
+ Project commands accept `--path` to select a working directory. Build, update, clean, and publish accept `--type`, direct flags such as `--python`, and exclusions such as `--nopython` or `--no-python`. Use `--quiet` to suppress progress. Errors go to stderr and cause a nonzero exit status.
38
+
39
+ External tools must already be available on PATH. Commands run with explicit argument arrays and working directories. On Windows, standard Node and Composer `.cmd`/`.bat` shims are resolved to their entry points without a command shell. Custom batch launchers are rejected with an explanatory error.
40
+
41
+ Production Composer installation (`up --prod` and WordPress builds) preserves the lockfile and installs with `--no-dev`. Normal Composer updates retain the existing dependency-refresh behavior. Python build/publish expands distribution files explicitly.
42
+
43
+ ## Transcript options
44
+
45
+ Use `--project <text>` repeatedly to filter projects, `--since-days 0` to include all dates, and `--last N` to select the newest N matched sessions across projects. `--list` lists without exporting. Rendering supports `--user-only`, `--no-include-tools`, `--no-include-thinking`, and `--include-subagents`.
46
+
47
+ Optimization accepts `--in` for an existing export. It copies only indexed sessions to a fresh analysis directory before redacting them, preserving the original export. `--out` must name an empty directory; omitted output paths receive a unique suffix. `--dry-run` prepares the redacted snapshot and prints the agent command without launching it. Secret removal covers known project `.env` values and secret-like assignments, including summaries in the index.
48
+
49
+ ## Source layout
50
+
51
+ ```text
52
+ src/
53
+ cli/ entry point, registration, shared CLI options
54
+ core/ subprocesses, files, JSON guards, logging, project detection
55
+ features/
56
+ build/ clean/ update/ publish/ package/ yarn/
57
+ transcripts/ extraction, rendering, types, JSONL readers
58
+ sources/ Claude and Codex adapters
59
+ optimize-transcripts/ snapshots, redaction, prompts, agent execution
60
+ tests/
61
+ fixtures/ synthetic JSONL sessions
62
+ scripts/ build and test entry points
63
+ ```
64
+
65
+ Each feature owns a typed yargs command module and its implementation. Shared subprocesses use `core/process.ts`; feature code lets failures reach the CLI boundary. Tests use temporary project fixtures and injected command runners, so the suite does not publish packages or run Docker/AI services. The test script type-checks tests and source, discovers every `tests/*.test.ts`, and keeps temporary files inside the project.
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createCli = void 0;
7
+ const yargs_1 = __importDefault(require("yargs/yargs"));
8
+ const command_1 = __importDefault(require("../features/build/command"));
9
+ const command_2 = __importDefault(require("../features/clean/command"));
10
+ const command_3 = __importDefault(require("../features/update/command"));
11
+ const command_4 = __importDefault(require("../features/publish/command"));
12
+ const command_5 = __importDefault(require("../features/package/command"));
13
+ const command_6 = __importDefault(require("../features/transcripts/command"));
14
+ const command_7 = __importDefault(require("../features/optimize-transcripts/command"));
15
+ const command_8 = __importDefault(require("../features/verify-changes/command"));
16
+ const commands_1 = require("../features/yarn/commands");
17
+ function createCli(args) {
18
+ return (0, yargs_1.default)(args)
19
+ .scriptName('azcli')
20
+ .usage('Usage: $0 <command> [options]')
21
+ .option('quiet', { alias: ['q', 's'], type: 'boolean', describe: 'Suppress progress and subprocess output' })
22
+ .command(command_1.default)
23
+ .command(command_2.default)
24
+ .command(command_3.default)
25
+ .command(command_4.default)
26
+ .command(command_5.default)
27
+ .command(command_6.default)
28
+ .command(command_7.default)
29
+ .command(command_8.default)
30
+ .command(commands_1.installCommand)
31
+ .command(commands_1.buildCommand)
32
+ .command(commands_1.testCommand)
33
+ .demandCommand(1)
34
+ .strict()
35
+ .help()
36
+ .exitProcess(false)
37
+ .fail((message, error) => { throw error ?? new Error(message); });
38
+ }
39
+ exports.createCli = createCli;
40
+ //# sourceMappingURL=create-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-cli.js","sourceRoot":"","sources":["../../src/cli/create-cli.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,wEAA8C;AAC9C,wEAA8C;AAC9C,yEAAgD;AAChD,0EAAkD;AAClD,0EAAmD;AACnD,8EAA0D;AAC1D,uFAAgE;AAChE,iFAA+D;AAC/D,wDAAsF;AAEtF,SAAgB,SAAS,CAAC,IAAc;IACvC,OAAO,IAAA,eAAK,EAAC,IAAI,CAAC;SAChB,UAAU,CAAC,OAAO,CAAC;SACnB,KAAK,CAAC,+BAA+B,CAAC;SACtC,MAAM,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,yCAAyC,EAAE,CAAC;SAC5G,OAAO,CAAC,iBAAK,CAAC;SACd,OAAO,CAAC,iBAAK,CAAC;SACd,OAAO,CAAC,iBAAM,CAAC;SACf,OAAO,CAAC,iBAAO,CAAC;SAChB,OAAO,CAAC,iBAAQ,CAAC;SACjB,OAAO,CAAC,iBAAW,CAAC;SACpB,OAAO,CAAC,iBAAQ,CAAC;SACjB,OAAO,CAAC,iBAAa,CAAC;SACtB,OAAO,CAAC,yBAAc,CAAC;SACvB,OAAO,CAAC,uBAAY,CAAC;SACrB,OAAO,CAAC,sBAAW,CAAC;SACpB,aAAa,CAAC,CAAC,CAAC;SAChB,MAAM,EAAE;SACR,IAAI,EAAE;SACN,WAAW,CAAC,KAAK,CAAC;SAClB,IAAI,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AArBD,8BAqBC"}
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.main = void 0;
5
+ const helpers_1 = require("yargs/helpers");
6
+ const create_cli_1 = require("./create-cli");
7
+ const logger_1 = require("../core/logger");
8
+ async function main(args = (0, helpers_1.hideBin)(process.argv)) {
9
+ try {
10
+ await (0, create_cli_1.createCli)(args).parseAsync();
11
+ }
12
+ catch (error) {
13
+ (0, logger_1.showError)(error);
14
+ process.exitCode = 1;
15
+ }
16
+ }
17
+ exports.main = main;
18
+ if (require.main === module)
19
+ void main();
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;AAEA,2CAAwC;AACxC,6CAAyC;AACzC,2CAA2C;AAEpC,KAAK,UAAU,IAAI,CAAC,IAAI,GAAG,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC;IACtD,IAAI;QACH,MAAM,IAAA,sBAAS,EAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;KACnC;IAAC,OAAO,KAAK,EAAE;QACf,IAAA,kBAAS,EAAC,KAAK,CAAC,CAAC;QACjB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;KACrB;AACF,CAAC;AAPD,oBAOC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;IAAE,KAAK,IAAI,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.projectOptions = void 0;
4
+ const project_type_1 = require("../core/project-type");
5
+ exports.projectOptions = {
6
+ type: { alias: 't', describe: 'Project type', choices: project_type_1.projectTypes, type: 'string' },
7
+ path: { describe: 'Project directory', type: 'string' },
8
+ php: { type: 'boolean' },
9
+ yarn: { type: 'boolean' },
10
+ python: { type: 'boolean' },
11
+ docker: { type: 'boolean' },
12
+ nophp: { type: 'boolean' },
13
+ noyarn: { type: 'boolean' },
14
+ nopython: { type: 'boolean' },
15
+ nodocker: { type: 'boolean' },
16
+ };
17
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/cli/options.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAEvC,QAAA,cAAc,GAAG;IAC7B,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,2BAAY,EAAE,IAAI,EAAE,QAAQ,EAAE;IACrF,IAAI,EAAE,EAAE,QAAQ,EAAE,mBAAmB,EAAE,IAAI,EAAE,QAAQ,EAAE;IACvD,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IACxB,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IACzB,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC3B,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC3B,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC1B,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC3B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC7B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;CACK,CAAC"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveInside = exports.removeMatching = exports.copyFile = exports.ensureDirectory = exports.removeIfExists = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const logger_1 = require("./logger");
11
+ const rimraf_1 = require("rimraf");
12
+ function removeIfExists(rm_path, log = false) {
13
+ if (!node_fs_1.default.existsSync(rm_path))
14
+ return false;
15
+ const fullpath = node_path_1.default.resolve(rm_path);
16
+ const isDir = node_fs_1.default.lstatSync(fullpath).isDirectory();
17
+ if (!isDir)
18
+ node_fs_1.default.unlinkSync(fullpath);
19
+ else
20
+ node_fs_1.default.rmSync(fullpath, { recursive: true, force: true });
21
+ if (log)
22
+ (0, logger_1.showMessage)('rm: ' + fullpath, 'danger', false);
23
+ return true;
24
+ }
25
+ exports.removeIfExists = removeIfExists;
26
+ function ensureDirectory(rm_path) {
27
+ const fullpath = node_path_1.default.resolve(rm_path);
28
+ if (!node_fs_1.default.existsSync(fullpath)) {
29
+ node_fs_1.default.mkdirSync(fullpath, { recursive: true });
30
+ return true;
31
+ }
32
+ return false;
33
+ }
34
+ exports.ensureDirectory = ensureDirectory;
35
+ function copyFile(fromPath, toPath) {
36
+ if (!node_fs_1.default.existsSync(fromPath))
37
+ return false;
38
+ if (node_path_1.default.basename(fromPath).startsWith('.'))
39
+ return false; //cant copy hiddens
40
+ if (node_fs_1.default.existsSync(toPath)) {
41
+ const isDir = node_fs_1.default.lstatSync(toPath).isDirectory();
42
+ if (isDir) {
43
+ //targetPath is a directory
44
+ const mfileName = node_path_1.default.basename(fromPath);
45
+ toPath = node_path_1.default.resolve(toPath, mfileName);
46
+ }
47
+ }
48
+ if (fromPath === toPath)
49
+ return false;
50
+ fs_extra_1.default.copySync(fromPath, toPath);
51
+ return true;
52
+ }
53
+ exports.copyFile = copyFile;
54
+ async function removeMatching(pattern, cwd) {
55
+ return (0, rimraf_1.rimraf)(pattern.replaceAll('\\', '/'), { glob: { cwd, dot: true, absolute: true } });
56
+ }
57
+ exports.removeMatching = removeMatching;
58
+ /** Reject traversal and symlink escapes before reading or writing indexed files. */
59
+ function resolveInside(root, relative) {
60
+ if (!relative || node_path_1.default.isAbsolute(relative))
61
+ throw new Error(`Expected a relative file path: ${relative}`);
62
+ const base = node_path_1.default.resolve(root);
63
+ const target = node_path_1.default.resolve(base, relative);
64
+ const isInside = (parent, child) => {
65
+ const rel = node_path_1.default.relative(parent, child);
66
+ return rel !== '' && rel !== '..' && !rel.startsWith('..' + node_path_1.default.sep) && !node_path_1.default.isAbsolute(rel);
67
+ };
68
+ if (!isInside(base, target))
69
+ throw new Error(`Path escapes directory: ${relative}`);
70
+ if (node_fs_1.default.existsSync(base)) {
71
+ let existing = target;
72
+ while (!node_fs_1.default.existsSync(existing))
73
+ existing = node_path_1.default.dirname(existing);
74
+ const realBase = node_fs_1.default.realpathSync(base);
75
+ const realExisting = node_fs_1.default.realpathSync(existing);
76
+ if (realExisting !== realBase && !isInside(realBase, realExisting))
77
+ throw new Error(`Symlink escapes directory: ${relative}`);
78
+ }
79
+ return target;
80
+ }
81
+ exports.resolveInside = resolveInside;
82
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/core/files.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,wDAA+B;AAC/B,0DAA6B;AAC7B,qCAAuC;AACvC,mCAAgC;AAEhC,SAAgB,cAAc,CAAC,OAAe,EAAE,GAAG,GAAG,KAAK;IAC1D,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,MAAM,QAAQ,GAAG,mBAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEvC,MAAM,KAAK,GAAG,iBAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IACnD,IAAI,CAAC,KAAK;QAAE,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;;QAC/B,iBAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,IAAI,GAAG;QAAE,IAAA,oBAAW,EAAC,MAAM,GAAG,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAEzD,OAAO,IAAI,CAAC;AACb,CAAC;AAVD,wCAUC;AACD,SAAgB,eAAe,CAAC,OAAe;IAC9C,MAAM,QAAQ,GAAG,mBAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEvC,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC7B,iBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EA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AlBD,sCAkBC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asString = exports.asRecord = exports.isRecord = void 0;
4
+ function isRecord(value) {
5
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
6
+ }
7
+ exports.isRecord = isRecord;
8
+ function asRecord(value) {
9
+ return isRecord(value) ? value : {};
10
+ }
11
+ exports.asRecord = asRecord;
12
+ function asString(value) {
13
+ return typeof value === 'string' ? value : undefined;
14
+ }
15
+ exports.asString = asString;
16
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/core/json.ts"],"names":[],"mappings":";;;AAAA,SAAgB,QAAQ,CAAC,KAAc;IACtC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAFD,4BAEC;AAED,SAAgB,QAAQ,CAAC,KAAc;IACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACrC,CAAC;AAFD,4BAEC;AAED,SAAgB,QAAQ,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAFD,4BAEC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.showDivider = exports.showError = exports.showMessage = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ function showMessage(text, type = '', showCli = true) {
9
+ const message = Array.isArray(text) ? text.flat().map(String).join(' ') : text;
10
+ const error = type === 'error' || type === 'danger';
11
+ const prefix = showCli ? (error ? chalk_1.default.bgRed('[az-cli]') : chalk_1.default.bgGreen('[az-cli]')) + ' ' : '';
12
+ if (error)
13
+ console.error(prefix + message);
14
+ else
15
+ console.info(prefix + message);
16
+ }
17
+ exports.showMessage = showMessage;
18
+ function showError(error) {
19
+ showMessage(error instanceof Error ? error.message : String(error), 'error');
20
+ }
21
+ exports.showError = showError;
22
+ function showDivider() {
23
+ showMessage('--------------------------------------------------------------------------', 'text', false);
24
+ }
25
+ exports.showDivider = showDivider;
26
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,SAAgB,WAAW,CAC1B,IAAwB,EACxB,OAA8D,EAAE,EAChE,OAAO,GAAG,IAAI;IAEd,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/E,MAAM,KAAK,GAAG,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,CAAC;IACpD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,eAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAClG,IAAI,KAAK;QAAE,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;;QACtC,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;AACrC,CAAC;AAVD,kCAUC;AAED,SAAgB,SAAS,CAAC,KAAc;IACvC,WAAW,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;AAC9E,CAAC;AAFD,8BAEC;AAED,SAAgB,WAAW;IAC1B,WAAW,CAAC,4EAA4E,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAC1G,CAAC;AAFD,kCAEC"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runCommand = exports.resolveCommand = exports.CommandError = void 0;
7
+ const node_child_process_1 = require("node:child_process");
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ class CommandError extends Error {
11
+ command;
12
+ args;
13
+ code;
14
+ signal;
15
+ stderr;
16
+ stdout;
17
+ constructor(command, args, code, signal, stderr, stdout = '') {
18
+ super(`${command} ${args.join(' ')} failed (${signal ? `signal ${signal}` : `exit code ${code}`})${stderr.trim() ? `: ${stderr.trim()}` : ''}`);
19
+ this.command = command;
20
+ this.args = args;
21
+ this.code = code;
22
+ this.signal = signal;
23
+ this.stderr = stderr;
24
+ this.stdout = stdout;
25
+ this.name = 'CommandError';
26
+ }
27
+ }
28
+ exports.CommandError = CommandError;
29
+ function findWindowsExecutable(command, cwd, env) {
30
+ const envValue = (key) => Object.entries(env).find(([k]) => k.toUpperCase() === key)?.[1];
31
+ const directories = /[\\/]/.test(command)
32
+ ? ['']
33
+ : [cwd, ...(envValue('PATH') ?? '').split(';').filter(Boolean)];
34
+ const extensions = node_path_1.default.extname(command) ? [''] : (envValue('PATHEXT') ?? '.EXE;.COM;.CMD;.BAT').split(';');
35
+ for (const directory of directories) {
36
+ for (const extension of extensions) {
37
+ const file = node_path_1.default.resolve(cwd, directory.replace(/^"|"$/g, ''), command + extension);
38
+ if (node_fs_1.default.existsSync(file) && node_fs_1.default.statSync(file).isFile())
39
+ return file;
40
+ }
41
+ }
42
+ throw new Error(`Executable not found: ${command}`);
43
+ }
44
+ /** Launch standard Node/Composer Windows shims directly, without cmd.exe parsing arguments. */
45
+ function resolveCommand(command, args, cwd, env, platform = process.platform) {
46
+ if (platform !== 'win32')
47
+ return { command, args: [...args] };
48
+ const executable = findWindowsExecutable(command, cwd, env);
49
+ if (!/\.(cmd|bat)$/i.test(executable))
50
+ return { command: executable, args: [...args] };
51
+ const shim = node_fs_1.default.readFileSync(executable, 'utf8');
52
+ const relativeEntry = shim.match(/(?:"[^"\r\n]*(?:node(?:\.exe)?|%_prog%|php(?:\.exe)?)"|\bnode|\bphp)\s+"(?:%dp0%|%~dp0)[\\/]?([^"\r\n]+)"\s+%\*/i);
53
+ const absoluteEntry = shim.match(/"[^"\r\n]*node(?:\.exe)?"\s+"([^"\r\n]+)"\s+%\*/i);
54
+ const script = relativeEntry
55
+ ? node_path_1.default.resolve(node_path_1.default.dirname(executable), relativeEntry[1].replace(/[\\/]/g, node_path_1.default.sep))
56
+ : absoluteEntry && node_path_1.default.isAbsolute(absoluteEntry[1]) ? absoluteEntry[1] : undefined;
57
+ if (!script)
58
+ throw new Error(`Unsupported batch launcher: ${executable}. Use a native executable or a standard Node/Composer shim.`);
59
+ if (!node_fs_1.default.existsSync(script))
60
+ throw new Error(`Launcher entry point not found: ${script}`);
61
+ const siblingNode = node_path_1.default.join(node_path_1.default.dirname(executable), 'node.exe');
62
+ const runtime = /\.phar$/i.test(script)
63
+ ? findWindowsExecutable('php', cwd, env)
64
+ : node_fs_1.default.existsSync(siblingNode) ? siblingNode : process.execPath;
65
+ return { command: runtime, args: [script, ...args] };
66
+ }
67
+ exports.resolveCommand = resolveCommand;
68
+ /** All commands reject on spawn errors, nonzero exits, signals, and I/O failures. */
69
+ const runCommand = async (command, args = [], options = {}) => {
70
+ const cwd = node_path_1.default.resolve(options.cwd ?? process.cwd());
71
+ const env = options.env ?? process.env;
72
+ const launch = resolveCommand(command, args, cwd, env);
73
+ return new Promise((resolve, reject) => {
74
+ const child = (0, node_child_process_1.spawn)(launch.command, launch.args, { cwd, env, shell: false, windowsHide: true });
75
+ let stdout = '';
76
+ let stderr = '';
77
+ const fail = (error) => {
78
+ child.kill();
79
+ reject(error);
80
+ };
81
+ child.once('error', (error) => reject(new Error(`Could not start ${command}: ${error.message}`)));
82
+ child.stdout.setEncoding('utf8');
83
+ child.stderr.setEncoding('utf8');
84
+ child.stdout.on('error', fail);
85
+ child.stderr.on('error', fail);
86
+ child.stdin.on('error', (error) => {
87
+ // A process may exit before consuming stdin; its close event determines success.
88
+ if (error.code !== 'EPIPE')
89
+ fail(error);
90
+ });
91
+ child.stdout.on('data', (text) => {
92
+ stdout += text;
93
+ try {
94
+ if (!options.quiet)
95
+ process.stdout.write(text);
96
+ options.onStdout?.(text, child.stdin);
97
+ }
98
+ catch (error) {
99
+ fail(error instanceof Error ? error : new Error(String(error)));
100
+ }
101
+ });
102
+ child.stderr.on('data', (text) => {
103
+ stderr += text;
104
+ if (!options.quiet)
105
+ process.stderr.write(text);
106
+ });
107
+ child.once('close', (code, signal) => {
108
+ if (code !== 0 || signal)
109
+ reject(new CommandError(command, args, code, signal, stderr, stdout));
110
+ else
111
+ resolve({ code, stdout, stderr });
112
+ });
113
+ if (options.input !== undefined)
114
+ child.stdin.end(options.input);
115
+ else if (!options.onStdout)
116
+ child.stdin.end();
117
+ });
118
+ };
119
+ exports.runCommand = runCommand;
120
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/core/process.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA2C;AAC3C,sDAAyB;AACzB,0DAA6B;AAiB7B,MAAa,YAAa,SAAQ,KAAK;IAErB;IACA;IACA;IACA;IACA;IACA;IANjB,YACiB,OAAe,EACf,IAAuB,EACvB,IAAmB,EACnB,MAA6B,EAC7B,MAAc,EAC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,CAAC,OAAO,CAAC,QAAQ;YAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC;AAzCW,QAAA,UAAU,cAyCrB"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadProjectType = exports.getProjectType = exports.projectTypes = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const logger_1 = require("./logger");
10
+ exports.projectTypes = ['php', 'yarn', 'python', 'docker'];
11
+ const markers = {
12
+ php: ['composer.json', 'index.php'],
13
+ docker: ['compose.yml', 'compose.yaml', 'docker-compose.yml', 'docker-compose.yaml'],
14
+ python: ['pyproject.toml', 'pyproject.yaml', 'requirements.txt'],
15
+ yarn: ['package.json'],
16
+ };
17
+ function getProjectType(options = {}, cwd = options.path ?? process.cwd()) {
18
+ if (options.type)
19
+ return options.type;
20
+ const enabled = (type) => !options[`no${type}`] && options[type] !== false;
21
+ for (const type of exports.projectTypes) {
22
+ if (enabled(type) && (options[type] === true || options.mode === type))
23
+ return type;
24
+ }
25
+ for (const type of ['php', 'docker', 'python', 'yarn']) {
26
+ if (enabled(type) && markers[type].some((file) => node_fs_1.default.existsSync(node_path_1.default.join(cwd, file))))
27
+ return type;
28
+ }
29
+ return null;
30
+ }
31
+ exports.getProjectType = getProjectType;
32
+ function loadProjectType(options = {}) {
33
+ const type = getProjectType(options);
34
+ if (!type)
35
+ throw new Error('Could not detect project type. Specify --type.');
36
+ if (!options.quiet)
37
+ (0, logger_1.showMessage)(`detected project type: ${type}`, 'text');
38
+ return type;
39
+ }
40
+ exports.loadProjectType = loadProjectType;
41
+ //# sourceMappingURL=project-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-type.js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G,EAAE,IAAI,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;KACpG;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAVD,wCAUC;AAED,SAAgB,eAAe,CAAC,UAA0B,EAAE;IAC3D,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAC7E,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,IAAA,oBAAW,EAAC,0BAA0B,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;IAC1E,OAAO,IAAI,CAAC;AACb,CAAC;AALD,0CAKC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.customTrim = void 0;
4
+ function customTrim(s, ...mask_list) {
5
+ if (typeof s != 'string' || !s)
6
+ return s;
7
+ mask_list.map((mask) => {
8
+ if (!s || !mask)
9
+ return '';
10
+ while (s.startsWith(mask)) {
11
+ s = s.substring(mask.length);
12
+ }
13
+ while (s.endsWith(mask)) {
14
+ s = s.substring(0, s.length - mask.length);
15
+ }
16
+ });
17
+ return s;
18
+ }
19
+ exports.customTrim = customTrim;
20
+ //# sourceMappingURL=strings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.js","sourceRoot":"","sources":["../../src/core/strings.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,CAAC,CAAS,EAAE,GAAG,SAAmB;IAC3D,IAAI,OAAO,CAAC,IAAI,QAAQ,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACzC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACtB,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YAC1B,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC7B;QACD,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACxB,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;SAC3C;IACF,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,CAAC;AACV,CAAC;AAZD,gCAYC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildProject = exports.distributionFiles = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ const files_1 = require("../../core/files");
10
+ const process_1 = require("../../core/process");
11
+ const logger_1 = require("../../core/logger");
12
+ const wordpress_1 = __importDefault(require("./wordpress"));
13
+ function distributionFiles(cwd) {
14
+ const dir = node_path_1.default.join(cwd, 'dist');
15
+ const files = node_fs_1.default.existsSync(dir)
16
+ ? node_fs_1.default.readdirSync(dir, { withFileTypes: true }).filter((file) => file.isFile()).map((file) => node_path_1.default.join(dir, file.name))
17
+ : [];
18
+ if (files.length === 0)
19
+ throw new Error(`Nothing to publish or check: ${dir} is missing or empty. Run build first.`);
20
+ return files;
21
+ }
22
+ exports.distributionFiles = distributionFiles;
23
+ async function buildProject(type, options = {}, run = process_1.runCommand) {
24
+ const cwd = node_path_1.default.resolve(options.path ?? process.cwd());
25
+ const execution = { cwd, quiet: options.quiet };
26
+ switch (type) {
27
+ case 'php':
28
+ await (0, wordpress_1.default)({ ...options, path: cwd }, run);
29
+ break;
30
+ case 'yarn':
31
+ await run('yarn', ['run', 'build'], execution);
32
+ break;
33
+ case 'python':
34
+ (0, files_1.removeIfExists)(node_path_1.default.join(cwd, 'dist'));
35
+ await run('python', ['-m', 'build'], execution);
36
+ await run('python', ['-m', 'twine', 'check', '--strict', ...distributionFiles(cwd)], execution);
37
+ break;
38
+ case 'docker':
39
+ await run('docker', ['compose', 'up', '-d', '--build'], execution);
40
+ break;
41
+ }
42
+ if (!options.quiet)
43
+ (0, logger_1.showMessage)('Build done', 'text');
44
+ }
45
+ exports.buildProject = buildProject;
46
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/features/build/build.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,sDAAyB;AACzB,4CAAkD;AAClD,gDAA+D;AAE/D,8CAAgD;AAEhD,4DAAyC;AAEzC,SAAgB,iBAAiB,CAAC,GAAW;IAC5C,MAAM,GAAG,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,iBAAE,CAAC,UAAU,CAAC,GAAG,CAAC;QAC/B,CAAC,CAAC,iBAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACvH,CAAC,CAAC,EAAE,CAAC;IACN,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,GAAG,wCAAwC,CAAC,CAAC;IACrH,OAAO,KAAK,CAAC;AACd,CAAC;AAPD,8CAOC;AAEM,KAAK,UAAU,YAAY,CAAC,IAAiB,EAAE,UAAwB,EAAE,EAAE,MAAqB,oBAAU;IAChH,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;IAChD,QAAQ,IAAI,EAAE;QACb,KAAK,KAAK;YACT,MAAM,IAAA,mBAAc,EAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;YACrD,MAAM;QACP,KAAK,MAAM;YACV,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;YAC/C,MAAM;QACP,KAAK,QAAQ;YACZ,IAAA,sBAAc,EAAC,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;YACvC,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;YAChD,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;YAChG,MAAM;QACP,KAAK,QAAQ;YACZ,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC;YACnE,MAAM;KACP;IACD,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,IAAA,oBAAW,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AApBD,oCAoBC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const options_1 = require("../../cli/options");
4
+ const project_type_1 = require("../../core/project-type");
5
+ const build_1 = require("./build");
6
+ const command = {
7
+ command: 'build [mode]',
8
+ describe: 'Build the current project',
9
+ builder: (cli) => cli
10
+ .positional('mode', { type: 'string', choices: project_type_1.projectTypes })
11
+ .options(options_1.projectOptions)
12
+ .option('noupdate', { type: 'boolean', describe: 'Skip Composer updates for WordPress builds' })
13
+ .option('cleanup', { type: 'boolean', default: true, describe: 'Remove temporary WordPress build files' }),
14
+ handler: async (args) => { await (0, build_1.buildProject)((0, project_type_1.loadProjectType)(args), args); },
15
+ };
16
+ exports.default = command;
17
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/features/build/command.ts"],"names":[],"mappings":";;AACA,+CAAmD;AACnD,0DAAwF;AACxF,mCAAuC;AAIvC,MAAM,OAAO,GAAoC;IAChD,OAAO,EAAE,cAAc;IACvB,QAAQ,EAAE,2BAA2B;IACrC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;SACnB,UAAU,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,2BAAY,EAAE,CAAC;SAC7D,OAAO,CAAC,wBAAc,CAAC;SACvB,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,4CAA4C,EAAE,CAAC;SAC/F,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,wCAAwC,EAAE,CAAC;IAC3G,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,IAAA,oBAAY,EAAC,IAAA,8BAAe,EAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;CAC7E,CAAC;AACF,kBAAe,OAAO,CAAC"}