@pagepocket/cli 0.10.1 → 0.11.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 (49) hide show
  1. package/dist/commands/archive.js +146 -76
  2. package/dist/commands/plugin/add.js +19 -25
  3. package/dist/commands/plugin/doctor.js +22 -28
  4. package/dist/commands/plugin/ls.js +16 -22
  5. package/dist/commands/plugin/prune.js +13 -19
  6. package/dist/commands/plugin/remove.js +16 -22
  7. package/dist/commands/plugin/set.js +13 -19
  8. package/dist/commands/plugin/uninstall.js +29 -35
  9. package/dist/commands/plugin/update.js +22 -28
  10. package/dist/commands/strategy/add.js +14 -20
  11. package/dist/commands/strategy/doctor.js +11 -17
  12. package/dist/commands/strategy/ls.js +22 -0
  13. package/dist/commands/strategy/pin.js +10 -16
  14. package/dist/commands/strategy/remove.js +10 -16
  15. package/dist/commands/strategy/update.js +21 -27
  16. package/dist/commands/view.js +36 -42
  17. package/dist/index.js +9 -7
  18. package/dist/lib/filename.js +1 -5
  19. package/dist/services/config-service.js +24 -30
  20. package/dist/services/load-configured-plugins.js +8 -12
  21. package/dist/services/plugin-installer.js +6 -12
  22. package/dist/services/plugin-store.js +27 -68
  23. package/dist/services/strategy/builtin-strategy-registry.js +23 -0
  24. package/dist/services/strategy/strategy-analyze.js +10 -20
  25. package/dist/services/strategy/strategy-config.js +6 -13
  26. package/dist/services/strategy/strategy-fetch.js +11 -18
  27. package/dist/services/strategy/strategy-io.js +15 -25
  28. package/dist/services/strategy/strategy-normalize.js +4 -8
  29. package/dist/services/strategy/strategy-pack-read.js +10 -17
  30. package/dist/services/strategy/strategy-pack-store.js +12 -18
  31. package/dist/services/strategy/strategy-service.js +79 -82
  32. package/dist/services/strategy/types.js +1 -2
  33. package/dist/services/units/unit-store.js +16 -20
  34. package/dist/services/units/unit-validate.js +20 -5
  35. package/dist/services/user-packages/parse-pinned-spec.js +6 -6
  36. package/dist/services/user-packages/user-package-installer.js +4 -9
  37. package/dist/services/user-packages/user-package-store.js +19 -57
  38. package/dist/stages/prepare-output.js +6 -13
  39. package/dist/units/network-observer-unit.js +7 -10
  40. package/dist/utils/array.js +3 -0
  41. package/dist/utils/normalize-argv.js +3 -8
  42. package/dist/utils/parse-json.js +1 -5
  43. package/dist/utils/parse-plugin-options.js +1 -5
  44. package/dist/utils/parse-plugin-spec.js +6 -6
  45. package/dist/utils/validate-plugin-default-export.js +1 -5
  46. package/dist/utils/with-spinner.js +3 -10
  47. package/dist/view.js +12 -19
  48. package/package.json +12 -11
  49. package/dist/services/strategy/read-installed-package-version.js +0 -28
@@ -1,13 +1,8 @@
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
- const core_1 = require("@oclif/core");
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const config_service_1 = require("../../services/config-service");
9
- const parse_plugin_options_1 = require("../../utils/parse-plugin-options");
10
- const parse_plugin_spec_1 = require("../../utils/parse-plugin-spec");
1
+ import { Command } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import { ConfigService } from "../../services/config-service.js";
4
+ import { parsePluginOptions } from "../../utils/parse-plugin-options.js";
5
+ import { parsePluginSpec } from "../../utils/parse-plugin-spec.js";
11
6
  /**
12
7
  * Replace options for a configured plugin and keep its current name/spec.
13
8
  *
@@ -27,25 +22,27 @@ const buildUpdatedPluginEntry = (entry, options) => {
27
22
  options
28
23
  };
29
24
  };
30
- class PluginSetCommand extends core_1.Command {
25
+ export default class PluginSetCommand extends Command {
26
+ static description = "Update options for an already configured plugin.";
27
+ static strict = false;
31
28
  async run() {
32
29
  const [rawName, ...rest] = this.argv;
33
30
  if (!rawName) {
34
31
  throw new Error("plugin set: missing <plugin-name>");
35
32
  }
36
- const parsedOptions = (0, parse_plugin_options_1.parsePluginOptions)(rest);
33
+ const parsedOptions = parsePluginOptions(rest);
37
34
  if (parsedOptions.kind === "none") {
38
35
  throw new Error("plugin set: provide options with --option or --option-*");
39
36
  }
40
- const targetName = (0, parse_plugin_spec_1.parsePluginSpec)(rawName).name;
41
- const configService = new config_service_1.ConfigService();
37
+ const targetName = parsePluginSpec(rawName).name;
38
+ const configService = new ConfigService();
42
39
  configService.ensureConfigFileExists();
43
40
  const config = configService.readConfigOrDefault();
44
41
  const targetIndex = config.plugins.findIndex((entry) => {
45
42
  return (typeof entry === "string" ? entry : entry.name) === targetName;
46
43
  });
47
44
  if (targetIndex < 0) {
48
- this.log(chalk_1.default.gray(`Plugin not found in config: ${targetName}`));
45
+ this.log(chalk.gray(`Plugin not found in config: ${targetName}`));
49
46
  return;
50
47
  }
51
48
  const targetEntry = config.plugins[targetIndex];
@@ -60,9 +57,6 @@ class PluginSetCommand extends core_1.Command {
60
57
  ...config,
61
58
  plugins: nextPlugins
62
59
  });
63
- this.log(chalk_1.default.green(`Updated plugin options: ${targetName}`));
60
+ this.log(chalk.green(`Updated plugin options: ${targetName}`));
64
61
  }
65
62
  }
66
- PluginSetCommand.description = "Update options for an already configured plugin.";
67
- PluginSetCommand.strict = false;
68
- exports.default = PluginSetCommand;
@@ -1,29 +1,38 @@
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
- const core_1 = require("@oclif/core");
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const config_service_1 = require("../../services/config-service");
9
- const plugin_installer_1 = require("../../services/plugin-installer");
10
- const plugin_store_1 = require("../../services/plugin-store");
11
- const parse_plugin_spec_1 = require("../../utils/parse-plugin-spec");
12
- class PluginUninstallCommand extends core_1.Command {
1
+ import { Args, Command, Flags } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import { ConfigService } from "../../services/config-service.js";
4
+ import { uninstallPluginPackage } from "../../services/plugin-installer.js";
5
+ import { PluginStore } from "../../services/plugin-store.js";
6
+ import { parsePluginSpec } from "../../utils/parse-plugin-spec.js";
7
+ export default class PluginUninstallCommand extends Command {
8
+ static description = "Uninstall a plugin package from the plugin install directory (optional config removal).";
9
+ static args = {
10
+ name: Args.string({
11
+ description: "npm package name",
12
+ required: true
13
+ })
14
+ };
15
+ static flags = {
16
+ fromConfig: Flags.boolean({
17
+ description: "also remove the plugin from config",
18
+ aliases: ["from-config"],
19
+ default: false
20
+ })
21
+ };
13
22
  async run() {
14
23
  const { args, flags } = await this.parse(PluginUninstallCommand);
15
- const parsed = (0, parse_plugin_spec_1.parsePluginSpec)(args.name);
24
+ const parsed = parsePluginSpec(args.name);
16
25
  const targetName = parsed.name;
17
- const configService = new config_service_1.ConfigService();
18
- const store = new plugin_store_1.PluginStore(configService);
26
+ const configService = new ConfigService();
27
+ const store = new PluginStore(configService);
19
28
  configService.ensureConfigFileExists();
20
29
  const installedMeta = store.readInstalledPackageMeta(targetName);
21
30
  if (!installedMeta) {
22
- this.log(chalk_1.default.gray(`Plugin package is not installed: ${targetName}`));
31
+ this.log(chalk.gray(`Plugin package is not installed: ${targetName}`));
23
32
  }
24
33
  else {
25
- (0, plugin_installer_1.uninstallPluginPackage)(store, { packageName: targetName });
26
- this.log(chalk_1.default.green(`Uninstalled plugin package: ${targetName}`));
34
+ uninstallPluginPackage(store, { packageName: targetName });
35
+ this.log(chalk.green(`Uninstalled plugin package: ${targetName}`));
27
36
  }
28
37
  if (!flags.fromConfig) {
29
38
  return;
@@ -31,25 +40,10 @@ class PluginUninstallCommand extends core_1.Command {
31
40
  const config = configService.readConfigOrDefault();
32
41
  const out = store.removePluginFromConfig(config, targetName);
33
42
  if (!out.removed) {
34
- this.log(chalk_1.default.gray(`Plugin not found in config: ${targetName}`));
43
+ this.log(chalk.gray(`Plugin not found in config: ${targetName}`));
35
44
  return;
36
45
  }
37
46
  configService.writeConfig(out.config);
38
- this.log(chalk_1.default.green(`Removed from config: ${targetName}`));
47
+ this.log(chalk.green(`Removed from config: ${targetName}`));
39
48
  }
40
49
  }
41
- PluginUninstallCommand.description = "Uninstall a plugin package from the plugin install directory (optional config removal).";
42
- PluginUninstallCommand.args = {
43
- name: core_1.Args.string({
44
- description: "npm package name",
45
- required: true
46
- })
47
- };
48
- PluginUninstallCommand.flags = {
49
- fromConfig: core_1.Flags.boolean({
50
- description: "also remove the plugin from config",
51
- aliases: ["from-config"],
52
- default: false
53
- })
54
- };
55
- exports.default = PluginUninstallCommand;
@@ -1,14 +1,9 @@
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
- const core_1 = require("@oclif/core");
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const config_service_1 = require("../../services/config-service");
9
- const plugin_installer_1 = require("../../services/plugin-installer");
10
- const plugin_store_1 = require("../../services/plugin-store");
11
- const parse_plugin_spec_1 = require("../../utils/parse-plugin-spec");
1
+ import { Args, Command } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import { ConfigService } from "../../services/config-service.js";
4
+ import { updatePluginPackageToLatest } from "../../services/plugin-installer.js";
5
+ import { PluginStore, normalizePluginConfigEntry } from "../../services/plugin-store.js";
6
+ import { parsePluginSpec } from "../../utils/parse-plugin-spec.js";
12
7
  /**
13
8
  * Read configured plugins and return unique package names.
14
9
  *
@@ -19,38 +14,37 @@ const getUniqueConfiguredPluginNames = (store) => {
19
14
  const config = store.readConfig();
20
15
  return [
21
16
  ...new Set(config.plugins
22
- .map((entry) => (0, plugin_store_1.normalizePluginConfigEntry)(entry).name)
17
+ .map((entry) => normalizePluginConfigEntry(entry).name)
23
18
  .filter((name) => name.trim().length > 0))
24
19
  ];
25
20
  };
26
- class PluginUpdateCommand extends core_1.Command {
21
+ export default class PluginUpdateCommand extends Command {
22
+ static description = "Update one plugin (or all configured plugins) to latest.";
23
+ static args = {
24
+ name: Args.string({
25
+ description: "npm package name (optional; if omitted updates all configured plugins)",
26
+ required: false
27
+ })
28
+ };
27
29
  async run() {
28
30
  const { args } = await this.parse(PluginUpdateCommand);
29
- const configService = new config_service_1.ConfigService();
30
- const store = new plugin_store_1.PluginStore(configService);
31
+ const configService = new ConfigService();
32
+ const store = new PluginStore(configService);
31
33
  configService.ensureConfigFileExists();
32
- const targetName = args.name ? (0, parse_plugin_spec_1.parsePluginSpec)(args.name).name : undefined;
34
+ const targetName = args.name ? parsePluginSpec(args.name).name : undefined;
33
35
  const configuredNames = getUniqueConfiguredPluginNames(store);
34
36
  if (configuredNames.length === 0) {
35
- this.log(chalk_1.default.gray("No plugins configured."));
37
+ this.log(chalk.gray("No plugins configured."));
36
38
  return;
37
39
  }
38
40
  if (targetName && !configuredNames.includes(targetName)) {
39
- this.log(chalk_1.default.gray(`Plugin not found in config: ${targetName}`));
41
+ this.log(chalk.gray(`Plugin not found in config: ${targetName}`));
40
42
  return;
41
43
  }
42
44
  const namesToUpdate = targetName ? [targetName] : configuredNames;
43
45
  namesToUpdate.forEach((name) => {
44
- (0, plugin_installer_1.updatePluginPackageToLatest)(store, { packageName: name });
45
- this.log(chalk_1.default.green(`Updated plugin: ${name}`));
46
+ updatePluginPackageToLatest(store, { packageName: name });
47
+ this.log(chalk.green(`Updated plugin: ${name}`));
46
48
  });
47
49
  }
48
50
  }
49
- PluginUpdateCommand.description = "Update one plugin (or all configured plugins) to latest.";
50
- PluginUpdateCommand.args = {
51
- name: core_1.Args.string({
52
- description: "npm package name (optional; if omitted updates all configured plugins)",
53
- required: false
54
- })
55
- };
56
- exports.default = PluginUpdateCommand;
@@ -1,34 +1,28 @@
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
- const core_1 = require("@oclif/core");
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const strategy_service_1 = require("../../services/strategy/strategy-service");
9
- class StrategyAddCommand extends core_1.Command {
1
+ import { Args, Command, Flags } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import { StrategyService } from "../../services/strategy/strategy-service.js";
4
+ export default class StrategyAddCommand extends Command {
5
+ static description = "Install strategies from a file/url OR install a strategy pack from a pinned npm package (applies all *.strategy.json).";
6
+ static args = {
7
+ source: Args.string({ description: "strategy file/url OR pinned npm package", required: true })
8
+ };
9
+ static flags = {
10
+ force: Flags.boolean({ description: "overwrite existing strategy", default: false })
11
+ };
10
12
  async run() {
11
13
  const { args, flags } = await this.parse(StrategyAddCommand);
12
- const service = new strategy_service_1.StrategyService();
14
+ const service = new StrategyService();
13
15
  service.ensureConfigFileExists();
14
16
  const out = await service.addStrategy({
15
17
  source: args.source,
16
18
  force: flags.force === true
17
19
  });
18
20
  out.installedStrategies.forEach((name) => {
19
- this.log(chalk_1.default.green(`Added strategy: ${name}`));
21
+ this.log(chalk.green(`Added strategy: ${name}`));
20
22
  });
21
23
  out.installedRefs.forEach((ref) => {
22
- this.log(chalk_1.default.green(`Installed unit: ${ref}`));
24
+ this.log(chalk.green(`Installed unit: ${ref}`));
23
25
  });
24
26
  void flags;
25
27
  }
26
28
  }
27
- StrategyAddCommand.description = "Install strategies from a file/url OR install a strategy pack from a pinned npm package (applies all *.strategy.json).";
28
- StrategyAddCommand.args = {
29
- source: core_1.Args.string({ description: "strategy file/url OR pinned npm package", required: true })
30
- };
31
- StrategyAddCommand.flags = {
32
- force: core_1.Flags.boolean({ description: "overwrite existing strategy", default: false })
33
- };
34
- exports.default = StrategyAddCommand;
@@ -1,34 +1,28 @@
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
- const core_1 = require("@oclif/core");
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const strategy_service_1 = require("../../services/strategy/strategy-service");
9
- class StrategyDoctorCommand extends core_1.Command {
1
+ import { Command } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import { StrategyService } from "../../services/strategy/strategy-service.js";
4
+ export default class StrategyDoctorCommand extends Command {
5
+ static description = "Diagnose strategy conflicts and unit package drift.";
10
6
  async run() {
11
- const service = new strategy_service_1.StrategyService();
7
+ const service = new StrategyService();
12
8
  const report = service.doctor();
13
9
  report.conflicts.forEach((c) => {
14
- this.log(chalk_1.default.red(`[CONFLICT] ${c.name}`));
10
+ this.log(chalk.red(`[CONFLICT] ${c.name}`));
15
11
  Object.entries(c.versions).forEach(([version, strategies]) => {
16
- this.log(chalk_1.default.red(` ${version}: ${strategies.join(", ")}`));
12
+ this.log(chalk.red(` ${version}: ${strategies.join(", ")}`));
17
13
  });
18
14
  });
19
15
  report.drift.forEach((d) => {
20
- this.log(chalk_1.default.yellow(`[DRIFT] ${d.strategy}`));
16
+ this.log(chalk.yellow(`[DRIFT] ${d.strategy}`));
21
17
  d.items.forEach((item) => {
22
18
  const installed = typeof item.installed === "string" ? item.installed : "(not installed)";
23
- this.log(chalk_1.default.yellow(` ${item.name}: pinned ${item.pinned}, installed ${installed}`));
19
+ this.log(chalk.yellow(` ${item.name}: pinned ${item.pinned}, installed ${installed}`));
24
20
  });
25
21
  });
26
22
  if (report.conflicts.length === 0 && report.drift.length === 0) {
27
- this.log(chalk_1.default.green("Strategy doctor checks passed."));
23
+ this.log(chalk.green("Strategy doctor checks passed."));
28
24
  return;
29
25
  }
30
26
  throw new Error("Strategy doctor checks failed.");
31
27
  }
32
28
  }
33
- StrategyDoctorCommand.description = "Diagnose strategy conflicts and unit package drift.";
34
- exports.default = StrategyDoctorCommand;
@@ -0,0 +1,22 @@
1
+ import { Command } from "@oclif/core";
2
+ import { listBuiltinStrategyNames } from "../../services/strategy/builtin-strategy-registry.js";
3
+ import { StrategyService } from "../../services/strategy/strategy-service.js";
4
+ import { uniq } from "../../utils/array.js";
5
+ export default class StrategyLsCommand extends Command {
6
+ static description = "List available strategies.";
7
+ async run() {
8
+ const service = new StrategyService();
9
+ service.ensureConfigFileExists();
10
+ const builtin = listBuiltinStrategyNames();
11
+ const installed = service.listInstalledStrategyNames();
12
+ const names = uniq([...builtin, ...installed])
13
+ .map((n) => n.trim())
14
+ .filter((n) => n.length > 0)
15
+ .sort((a, b) => a.localeCompare(b));
16
+ if (names.length === 0) {
17
+ this.log("No strategies available.");
18
+ return;
19
+ }
20
+ names.forEach((n) => this.log(n));
21
+ }
22
+ }
@@ -1,21 +1,15 @@
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
- const core_1 = require("@oclif/core");
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const strategy_service_1 = require("../../services/strategy/strategy-service");
9
- class StrategyPinCommand extends core_1.Command {
1
+ import { Args, Command } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import { StrategyService } from "../../services/strategy/strategy-service.js";
4
+ export default class StrategyPinCommand extends Command {
5
+ static description = "Pin a strategy file to currently installed unit package versions.";
6
+ static args = {
7
+ name: Args.string({ description: "strategy name", required: true })
8
+ };
10
9
  async run() {
11
10
  const { args } = await this.parse(StrategyPinCommand);
12
- const service = new strategy_service_1.StrategyService();
11
+ const service = new StrategyService();
13
12
  service.pinStrategy(args.name);
14
- this.log(chalk_1.default.green(`Pinned strategy: ${args.name}`));
13
+ this.log(chalk.green(`Pinned strategy: ${args.name}`));
15
14
  }
16
15
  }
17
- StrategyPinCommand.description = "Pin a strategy file to currently installed unit package versions.";
18
- StrategyPinCommand.args = {
19
- name: core_1.Args.string({ description: "strategy name", required: true })
20
- };
21
- exports.default = StrategyPinCommand;
@@ -1,21 +1,15 @@
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
- const core_1 = require("@oclif/core");
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const strategy_service_1 = require("../../services/strategy/strategy-service");
9
- class StrategyRemoveCommand extends core_1.Command {
1
+ import { Args, Command } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import { StrategyService } from "../../services/strategy/strategy-service.js";
4
+ export default class StrategyRemoveCommand extends Command {
5
+ static description = "Remove an installed strategy.";
6
+ static args = {
7
+ name: Args.string({ description: "strategy name", required: true })
8
+ };
10
9
  async run() {
11
10
  const { args } = await this.parse(StrategyRemoveCommand);
12
- const service = new strategy_service_1.StrategyService();
11
+ const service = new StrategyService();
13
12
  service.removeStrategy(args.name);
14
- this.log(chalk_1.default.green(`Removed strategy: ${args.name}`));
13
+ this.log(chalk.green(`Removed strategy: ${args.name}`));
15
14
  }
16
15
  }
17
- StrategyRemoveCommand.description = "Remove an installed strategy.";
18
- StrategyRemoveCommand.args = {
19
- name: core_1.Args.string({ description: "strategy name", required: true })
20
- };
21
- exports.default = StrategyRemoveCommand;
@@ -1,34 +1,28 @@
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
- const core_1 = require("@oclif/core");
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const strategy_service_1 = require("../../services/strategy/strategy-service");
9
- class StrategyUpdateCommand extends core_1.Command {
1
+ import { Args, Command, Flags } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import { StrategyService } from "../../services/strategy/strategy-service.js";
4
+ export default class StrategyUpdateCommand extends Command {
5
+ static description = "Update a strategy (or all strategies).";
6
+ static args = {
7
+ name: Args.string({ description: "strategy name (optional)", required: false })
8
+ };
9
+ static flags = {
10
+ packageOnly: Flags.boolean({
11
+ description: "update unit packages to latest only",
12
+ default: false
13
+ })
14
+ };
10
15
  async run() {
11
16
  const { args, flags } = await this.parse(StrategyUpdateCommand);
12
- const service = new strategy_service_1.StrategyService();
17
+ const service = new StrategyService();
13
18
  await service.updateStrategy(args.name, { packageOnly: flags.packageOnly === true });
14
19
  if (flags.packageOnly) {
15
- this.log(chalk_1.default.yellow("WARNING: Updated unit packages without updating strategy files. This may cause version drift."));
16
- this.log(chalk_1.default.gray("If drift occurs, fix by updating packages to pinned versions:"));
17
- this.log(chalk_1.default.gray(` pp strategy update${args.name ? ` ${args.name}` : ""}`));
18
- this.log(chalk_1.default.gray("Or pin a strategy to installed versions:"));
19
- this.log(chalk_1.default.gray(` pp strategy pin ${args.name ?? "<strategy-name>"}`));
20
+ this.log(chalk.yellow("WARNING: Updated unit packages without updating strategy files. This may cause version drift."));
21
+ this.log(chalk.gray("If drift occurs, fix by updating packages to pinned versions:"));
22
+ this.log(chalk.gray(` pp strategy update${args.name ? ` ${args.name}` : ""}`));
23
+ this.log(chalk.gray("Or pin a strategy to installed versions:"));
24
+ this.log(chalk.gray(` pp strategy pin ${args.name ?? "<strategy-name>"}`));
20
25
  }
21
- this.log(chalk_1.default.green("Strategy update completed."));
26
+ this.log(chalk.green("Strategy update completed."));
22
27
  }
23
28
  }
24
- StrategyUpdateCommand.description = "Update a strategy (or all strategies).";
25
- StrategyUpdateCommand.args = {
26
- name: core_1.Args.string({ description: "strategy name (optional)", required: false })
27
- };
28
- StrategyUpdateCommand.flags = {
29
- packageOnly: core_1.Flags.boolean({
30
- description: "update unit packages to latest only",
31
- default: false
32
- })
33
- };
34
- exports.default = StrategyUpdateCommand;
@@ -1,63 +1,57 @@
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
- const node_fs_1 = __importDefault(require("node:fs"));
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const node_process_1 = __importDefault(require("node:process"));
9
- const core_1 = require("@oclif/core");
10
- const chalk_1 = __importDefault(require("chalk"));
11
- const view_1 = require("../view");
12
- class ViewCommand extends core_1.Command {
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import process from "node:process";
4
+ import { Args, Command, Flags } from "@oclif/core";
5
+ import chalk from "chalk";
6
+ import { createViewServer } from "../view.js";
7
+ export default class ViewCommand extends Command {
8
+ static description = "Serve a directory via a local static server (SPA fallback to index.html).";
9
+ static args = {
10
+ directory: Args.string({
11
+ description: "Directory to serve (must contain index.html)",
12
+ required: true
13
+ })
14
+ };
15
+ static flags = {
16
+ help: Flags.help({
17
+ char: "h"
18
+ }),
19
+ host: Flags.string({
20
+ description: "Host to bind",
21
+ default: "127.0.0.1"
22
+ }),
23
+ port: Flags.integer({
24
+ description: "Port to listen on (0 for random)",
25
+ default: 4173
26
+ })
27
+ };
13
28
  async run() {
14
29
  const { args, flags } = await this.parse(ViewCommand);
15
- const rootDir = node_path_1.default.resolve(node_process_1.default.cwd(), args.directory);
16
- const indexPath = node_path_1.default.join(rootDir, "index.html");
17
- const stat = await node_fs_1.default.promises.stat(rootDir).catch(() => undefined);
30
+ const rootDir = path.resolve(process.cwd(), args.directory);
31
+ const indexPath = path.join(rootDir, "index.html");
32
+ const stat = await fs.promises.stat(rootDir).catch(() => undefined);
18
33
  if (!stat || !stat.isDirectory()) {
19
34
  throw new Error(`view: directory not found: ${rootDir}`);
20
35
  }
21
- const indexStat = await node_fs_1.default.promises.stat(indexPath).catch(() => undefined);
36
+ const indexStat = await fs.promises.stat(indexPath).catch(() => undefined);
22
37
  if (!indexStat || !indexStat.isFile()) {
23
38
  throw new Error(`view: index.html not found under: ${rootDir}`);
24
39
  }
25
- const portFromEnv = node_process_1.default.env.PORT ? Number(node_process_1.default.env.PORT) : undefined;
40
+ const portFromEnv = process.env.PORT ? Number(process.env.PORT) : undefined;
26
41
  const port = typeof flags.port === "number"
27
42
  ? flags.port
28
43
  : typeof portFromEnv === "number"
29
44
  ? portFromEnv
30
45
  : 4173;
31
46
  if (!Number.isFinite(port) || port < 0 || port > 65535) {
32
- throw new Error(`Invalid --port: ${String(flags.port ?? node_process_1.default.env.PORT)}`);
47
+ throw new Error(`Invalid --port: ${String(flags.port ?? process.env.PORT)}`);
33
48
  }
34
- const server = await (0, view_1.createViewServer)({
49
+ const server = await createViewServer({
35
50
  rootDir,
36
51
  host: flags.host,
37
52
  port
38
53
  });
39
- this.log(`Serving ${chalk_1.default.cyan(rootDir)}`);
40
- this.log(chalk_1.default.green(server.url));
54
+ this.log(`Serving ${chalk.cyan(rootDir)}`);
55
+ this.log(chalk.green(server.url));
41
56
  }
42
57
  }
43
- ViewCommand.description = "Serve a directory via a local static server (SPA fallback to index.html).";
44
- ViewCommand.args = {
45
- directory: core_1.Args.string({
46
- description: "Directory to serve (must contain index.html)",
47
- required: true
48
- })
49
- };
50
- ViewCommand.flags = {
51
- help: core_1.Flags.help({
52
- char: "h"
53
- }),
54
- host: core_1.Flags.string({
55
- description: "Host to bind",
56
- default: "127.0.0.1"
57
- }),
58
- port: core_1.Flags.integer({
59
- description: "Port to listen on (0 for random)",
60
- default: 4173
61
- })
62
- };
63
- exports.default = ViewCommand;
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@oclif/core");
4
- const normalize_argv_1 = require("./utils/normalize-argv");
5
- (0, core_1.run)((0, normalize_argv_1.normalizeArgv)(process.argv.slice(2))).catch((error) => {
6
- const message = error && typeof error.message === "string" ? error.message : String(error);
1
+ import { execute } from "@oclif/core";
2
+ import { normalizeArgv } from "./utils/normalize-argv.js";
3
+ await execute({
4
+ dir: import.meta.url,
5
+ args: normalizeArgv(process.argv.slice(2))
6
+ }).catch((error) => {
7
+ const err = error;
8
+ const message = err && typeof err.message === "string" ? err.message : String(error);
7
9
  console.error(message);
8
- const exitCode = error && typeof error.exitCode === "number" ? error.exitCode : 1;
10
+ const exitCode = err && typeof err.exitCode === "number" ? err.exitCode : 1;
9
11
  process.exit(exitCode);
10
12
  });
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.safeFilename = void 0;
4
- const safeFilename = (input) => {
1
+ export const safeFilename = (input) => {
5
2
  const trimmed = input.trim();
6
3
  if (!trimmed) {
7
4
  return "snapshot";
@@ -11,4 +8,3 @@ const safeFilename = (input) => {
11
8
  .replace(/^_+|_+$/g, "")
12
9
  .slice(0, 120) || "snapshot");
13
10
  };
14
- exports.safeFilename = safeFilename;