@shell-shock/plugin-upgrade 0.1.3 → 0.1.5

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.
@@ -1,11 +1,13 @@
1
1
  const require_components_upgrade_builtin = require('./upgrade-builtin.cjs');
2
2
  const require_components_upgrade_command = require('./upgrade-command.cjs');
3
3
 
4
+ exports.CheckForUpdatesFunctionDeclaration = require_components_upgrade_builtin.CheckForUpdatesFunctionDeclaration;
4
5
  exports.FetchNpmPackageFunctionDeclaration = require_components_upgrade_builtin.FetchNpmPackageFunctionDeclaration;
5
- exports.GetLatestFunctionDeclaration = require_components_upgrade_builtin.GetLatestFunctionDeclaration;
6
+ exports.GetLatestVersionFunctionDeclaration = require_components_upgrade_builtin.GetLatestVersionFunctionDeclaration;
6
7
  exports.GetPackageManagerFunctionDeclaration = require_components_upgrade_builtin.GetPackageManagerFunctionDeclaration;
7
- exports.InstallFunctionDeclaration = require_components_upgrade_builtin.InstallFunctionDeclaration;
8
+ exports.GetUpgradeCommandFunctionDeclaration = require_components_upgrade_builtin.GetUpgradeCommandFunctionDeclaration;
8
9
  exports.LocateLockfileFunctionDeclaration = require_components_upgrade_builtin.LocateLockfileFunctionDeclaration;
9
10
  exports.LocatePackageJsonFunctionDeclaration = require_components_upgrade_builtin.LocatePackageJsonFunctionDeclaration;
10
11
  exports.UpgradeBuiltin = require_components_upgrade_builtin.UpgradeBuiltin;
11
- exports.UpgradeCommand = require_components_upgrade_command.UpgradeCommand;
12
+ exports.UpgradeCommand = require_components_upgrade_command.UpgradeCommand;
13
+ exports.UpgradeFunctionDeclaration = require_components_upgrade_builtin.UpgradeFunctionDeclaration;
@@ -1,3 +1,3 @@
1
- import { FetchNpmPackageFunctionDeclaration, GetLatestFunctionDeclaration, GetPackageManagerFunctionDeclaration, InstallFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps } from "./upgrade-builtin.cjs";
1
+ import { CheckForUpdatesFunctionDeclaration, FetchNpmPackageFunctionDeclaration, GetLatestVersionFunctionDeclaration, GetPackageManagerFunctionDeclaration, GetUpgradeCommandFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps, UpgradeFunctionDeclaration } from "./upgrade-builtin.cjs";
2
2
  import { UpgradeCommand } from "./upgrade-command.cjs";
3
- export { FetchNpmPackageFunctionDeclaration, GetLatestFunctionDeclaration, GetPackageManagerFunctionDeclaration, InstallFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps, UpgradeCommand };
3
+ export { CheckForUpdatesFunctionDeclaration, FetchNpmPackageFunctionDeclaration, GetLatestVersionFunctionDeclaration, GetPackageManagerFunctionDeclaration, GetUpgradeCommandFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps, UpgradeCommand, UpgradeFunctionDeclaration };
@@ -1,3 +1,3 @@
1
- import { FetchNpmPackageFunctionDeclaration, GetLatestFunctionDeclaration, GetPackageManagerFunctionDeclaration, InstallFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps } from "./upgrade-builtin.mjs";
1
+ import { CheckForUpdatesFunctionDeclaration, FetchNpmPackageFunctionDeclaration, GetLatestVersionFunctionDeclaration, GetPackageManagerFunctionDeclaration, GetUpgradeCommandFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps, UpgradeFunctionDeclaration } from "./upgrade-builtin.mjs";
2
2
  import { UpgradeCommand } from "./upgrade-command.mjs";
3
- export { FetchNpmPackageFunctionDeclaration, GetLatestFunctionDeclaration, GetPackageManagerFunctionDeclaration, InstallFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps, UpgradeCommand };
3
+ export { CheckForUpdatesFunctionDeclaration, FetchNpmPackageFunctionDeclaration, GetLatestVersionFunctionDeclaration, GetPackageManagerFunctionDeclaration, GetUpgradeCommandFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps, UpgradeCommand, UpgradeFunctionDeclaration };
@@ -1,4 +1,4 @@
1
- import { FetchNpmPackageFunctionDeclaration, GetLatestFunctionDeclaration, GetPackageManagerFunctionDeclaration, InstallFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin } from "./upgrade-builtin.mjs";
1
+ import { CheckForUpdatesFunctionDeclaration, FetchNpmPackageFunctionDeclaration, GetLatestVersionFunctionDeclaration, GetPackageManagerFunctionDeclaration, GetUpgradeCommandFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeFunctionDeclaration } from "./upgrade-builtin.mjs";
2
2
  import { UpgradeCommand } from "./upgrade-command.mjs";
3
3
 
4
- export { FetchNpmPackageFunctionDeclaration, GetLatestFunctionDeclaration, GetPackageManagerFunctionDeclaration, InstallFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeCommand };
4
+ export { CheckForUpdatesFunctionDeclaration, FetchNpmPackageFunctionDeclaration, GetLatestVersionFunctionDeclaration, GetPackageManagerFunctionDeclaration, GetUpgradeCommandFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeCommand, UpgradeFunctionDeclaration };
@@ -1,30 +1,41 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
3
+ let defu = require("defu");
4
+ defu = require_rolldown_runtime.__toESM(defu);
3
5
  let __alloy_js_core = require("@alloy-js/core");
4
6
  let __alloy_js_typescript = require("@alloy-js/typescript");
5
7
  let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
8
+ let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
6
9
  let __powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
7
10
  let __powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
8
- let defu = require("defu");
9
- defu = require_rolldown_runtime.__toESM(defu);
10
11
 
11
12
  //#region src/components/upgrade-builtin.tsx
12
13
  /**
13
14
  * The `locatePackageJson` handler function declaration code for the Shell Shock project.
14
15
  */
15
16
  function LocatePackageJsonFunctionDeclaration() {
17
+ const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
16
18
  return [
17
19
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
18
20
  "export": true,
19
21
  name: "LocatePackageJsonOptions",
20
22
  doc: "Options for the `locatePackageJson` handler function.",
21
23
  get children() {
22
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
23
- name: "cwd",
24
- optional: true,
25
- type: "string",
26
- doc: "The current working directory to use. If not provided, the process's current working directory will be used."
27
- });
24
+ return [
25
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
26
+ name: "cwd",
27
+ optional: true,
28
+ type: "string",
29
+ doc: "The current working directory to use. If not provided, the process's current working directory will be used."
30
+ }),
31
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
32
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
33
+ name: "isDependencyRequired",
34
+ optional: true,
35
+ type: "boolean",
36
+ doc: "Whether to only locate a package.json file if it contains the application as a dependency. If set to `true`, the function will check if the located package.json file has the application listed as a dependency in its dependencies, devDependencies, peerDependencies, or optionalDependencies before returning its path. This can be useful in monorepo setups where multiple package.json files may exist, but only the one that includes the application as a dependency is relevant for upgrade purposes."
37
+ })
38
+ ];
28
39
  }
29
40
  }),
30
41
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
@@ -68,11 +79,32 @@ function LocatePackageJsonFunctionDeclaration() {
68
79
  }),
69
80
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
70
81
  __alloy_js_core.code`while (parentPath !== currentPath && currentPath !== homePath && currentPath !== tempPath) { `,
71
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
72
- condition: __alloy_js_core.code`existsSync(join(currentPath, "package.json"))`,
73
- children: __alloy_js_core.code`return join(currentPath, "package.json"); `
82
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
83
+ "const": true,
84
+ name: "packageJsonPath",
85
+ initializer: __alloy_js_core.code`join(currentPath, "package.json"); `
74
86
  }),
75
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`currentPath = pathParent;
87
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
88
+ condition: __alloy_js_core.code`existsSync(packageJsonPath)`,
89
+ get children() {
90
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
91
+ condition: __alloy_js_core.code`options.isDependencyRequired`,
92
+ get children() {
93
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
94
+ "const": true,
95
+ name: "packageJson",
96
+ initializer: __alloy_js_core.code`JSON.parse(await readFile(packageJsonPath, "utf8")); `
97
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
98
+ get condition() {
99
+ return __alloy_js_core.code`Object.keys(packageJson.dependencies || {}).concat(Object.keys(packageJson.devDependencies || {})).concat(Object.keys(packageJson.peerDependencies || {})).concat(Object.keys(packageJson.optionalDependencies || {})).some(dep => dep === "${context.packageJson.name}" || dep.startsWith("${context.packageJson.name}@"))`;
100
+ },
101
+ children: __alloy_js_core.code`return packageJsonPath; `
102
+ })];
103
+ }
104
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`return packageJsonPath; ` })];
105
+ }
106
+ }),
107
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`currentPath = parentPath;
76
108
  parentPath = resolve(currentPath, ".."); ` }),
77
109
  __alloy_js_core.code` }
78
110
 
@@ -117,7 +149,6 @@ function LocateLockfileFunctionDeclaration() {
117
149
  }),
118
150
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
119
151
  "export": true,
120
- async: true,
121
152
  name: "locateLockfile",
122
153
  parameters: [{
123
154
  name: "options",
@@ -162,7 +193,7 @@ function LocateLockfileFunctionDeclaration() {
162
193
  condition: __alloy_js_core.code`lockfile`,
163
194
  children: __alloy_js_core.code`return lockfile; `
164
195
  }),
165
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`currentPath = pathParent;
196
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`currentPath = parentPath;
166
197
  parentPath = resolve(currentPath, ".."); ` }),
167
198
  __alloy_js_core.code` }
168
199
 
@@ -177,6 +208,15 @@ function LocateLockfileFunctionDeclaration() {
177
208
  */
178
209
  function GetPackageManagerFunctionDeclaration() {
179
210
  return [
211
+ __alloy_js_core.code`declare global {
212
+ var Bun: any;
213
+ namespace NodeJS {
214
+ interface ProcessVersions {
215
+ bun?: string;
216
+ }
217
+ }
218
+ } `,
219
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
180
220
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TypeDeclaration, {
181
221
  "export": true,
182
222
  name: "GetPackageManagerOptions",
@@ -265,7 +305,7 @@ function GetPackageManagerFunctionDeclaration() {
265
305
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
266
306
  "const": true,
267
307
  name: "packageJsonPath",
268
- initializer: __alloy_js_core.code`locatePackageJson(options); `
308
+ initializer: __alloy_js_core.code`await locatePackageJson(options); `
269
309
  }),
270
310
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
271
311
  condition: __alloy_js_core.code`packageJsonPath && existsSync(packageJsonPath)`,
@@ -512,9 +552,10 @@ function FetchNpmPackageFunctionDeclaration() {
512
552
  ];
513
553
  }
514
554
  /**
515
- * The `getLatest` handler function declaration code for the Shell Shock project.
555
+ * The `getLatestVersion` handler function declaration code for the Shell Shock project.
516
556
  */
517
- function GetLatestFunctionDeclaration() {
557
+ function GetLatestVersionFunctionDeclaration() {
558
+ const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
518
559
  return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDoc, {
519
560
  heading: "Get the latest version of the application from the npm registry.",
520
561
  get children() {
@@ -531,89 +572,172 @@ function GetLatestFunctionDeclaration() {
531
572
  }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
532
573
  "export": true,
533
574
  async: true,
534
- name: "getLatest",
575
+ name: "getLatestVersion",
576
+ get parameters() {
577
+ return [{
578
+ name: "packageName",
579
+ default: `"${context.packageJson.name}"`
580
+ }];
581
+ },
582
+ returnType: __alloy_js_core.code`Promise<string | undefined>`,
583
+ get children() {
584
+ return [
585
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
586
+ "const": true,
587
+ name: "result",
588
+ initializer: __alloy_js_core.code`await fetchNpmPackage(packageName); `
589
+ }),
590
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
591
+ __alloy_js_core.code`return result?.version; `
592
+ ];
593
+ }
594
+ })];
595
+ }
596
+ /**
597
+ * The `upgrade` handler function declaration code for the Shell Shock project.
598
+ */
599
+ function GetUpgradeCommandFunctionDeclaration() {
600
+ const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
601
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDoc, {
602
+ heading: "A function to get the upgrade command for a specific package manager.",
603
+ get children() {
604
+ return [
605
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocRemarks, { children: `This function is used to get the appropriate upgrade command for a specific package manager. It can be used in the CLI upgrade command to determine which command to run based on the package manager being used by the application.` }),
606
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
607
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocParam, {
608
+ name: "packageManager",
609
+ children: `The name of the package manager to get the upgrade command for. This should be one of "npm", "yarn", "pnpm", "deno", or "bun".`
610
+ }),
611
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocParam, {
612
+ name: "cwd",
613
+ children: `The current working directory to use when determining the upgrade command. This can be used to locate the appropriate package.json and lockfile to determine how to run the upgrade command. If not provided, the process's current working directory will be used.`
614
+ }),
615
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocReturns, { children: `An array of strings representing the command and its arguments to run in order to upgrade the application dependencies using the specified package manager.` })
616
+ ];
617
+ }
618
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
619
+ "export": true,
620
+ async: true,
621
+ name: "getUpgradeCommand",
535
622
  parameters: [{
536
- name: "packageName",
623
+ name: "packageManager",
537
624
  type: "string"
625
+ }, {
626
+ name: "cwd",
627
+ type: "string",
628
+ default: "process.cwd()"
538
629
  }],
630
+ returnType: "Promise<string[]>",
539
631
  get children() {
540
632
  return [
541
633
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
542
634
  "const": true,
543
- name: "package",
544
- initializer: __alloy_js_core.code`await fetchNpmPackage(packageName); `
635
+ name: "version",
636
+ get initializer() {
637
+ return __alloy_js_core.code`(await getLatestVersion("${context.packageJson.name}")) || "latest"; `;
638
+ }
545
639
  }),
546
640
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
547
- __alloy_js_core.code`return package?.version; `
641
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
642
+ condition: __alloy_js_core.code`packageManager === "yarn"`,
643
+ get children() {
644
+ return __alloy_js_core.code`return ["upgrade", \`${context.packageJson.name}@\${version}\`]; `;
645
+ }
646
+ }),
647
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
648
+ condition: __alloy_js_core.code`packageManager === "pnpm"`,
649
+ get children() {
650
+ return __alloy_js_core.code`return ["update", \`${context.packageJson.name}@\${version}\`]; `;
651
+ }
652
+ }),
653
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
654
+ condition: __alloy_js_core.code`packageManager === "deno"`,
655
+ get children() {
656
+ return __alloy_js_core.code`return ["outdated", "--update", \`${context.packageJson.name}@\${version}\`]; `;
657
+ }
658
+ }),
659
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
660
+ condition: __alloy_js_core.code`packageManager === "bun"`,
661
+ get children() {
662
+ return __alloy_js_core.code`return ["update", "--save", \`${context.packageJson.name}@\${version}\`]; `;
663
+ }
664
+ }),
665
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { get children() {
666
+ return __alloy_js_core.code`return ["update", "--save", "--bin-links", \`${context.packageJson.name}@\${version}\`]; `;
667
+ } })
548
668
  ];
549
669
  }
550
670
  })];
551
671
  }
552
672
  /**
553
- * The `install` handler function declaration code for the Shell Shock project.
673
+ * The `upgrade` handler function declaration code for the Shell Shock project.
554
674
  */
555
- function InstallFunctionDeclaration() {
675
+ function UpgradeFunctionDeclaration() {
556
676
  return [
557
677
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
558
- "export": true,
559
- name: "InstallOptions",
560
- doc: "Options for the `install` handler function.",
678
+ name: "UpgradeBaseOptions",
679
+ doc: "Options for the `upgrade` handler function.",
561
680
  get children() {
562
681
  return [
563
682
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
564
683
  name: "stdout",
565
684
  optional: true,
566
- type: "(string) => void",
685
+ type: "(data: string) => void",
567
686
  doc: "A callback function that is called with the stdout output of the command."
568
687
  }),
569
688
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
570
689
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
571
690
  name: "stderr",
572
691
  optional: true,
573
- type: "(string) => void",
692
+ type: "(err: string) => void",
574
693
  doc: "A callback function that is called with the stderr output of the command."
575
- }),
576
- (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
577
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
578
- name: "color",
579
- optional: true,
580
- type: "boolean",
581
- doc: "Whether to enable color output in the command. If not provided, color output will be enabled by default."
582
694
  })
583
695
  ];
584
696
  }
585
697
  }),
586
698
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
699
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TypeDeclaration, {
700
+ "export": true,
701
+ name: "UpgradeOptions",
702
+ doc: "Options for the `upgrade` handler function.",
703
+ children: __alloy_js_core.code`UpgradeBaseOptions & GetPackageManagerOptions & Parameters<typeof spawn>[2];`
704
+ }),
705
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
587
706
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDoc, {
588
- heading: "Install the application dependencies.",
707
+ heading: "Upgrade the application dependencies.",
589
708
  get children() {
590
709
  return [
591
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocRemarks, { children: `This function is used to install the application dependencies. It can be used in the CLI upgrade command to ensure that all necessary dependencies are installed.` }),
710
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocRemarks, { children: `This function is used to upgrade the application dependencies. It can be used in the CLI upgrade command to ensure that all necessary dependencies are up-to-date.` }),
592
711
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
593
712
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocParam, {
594
713
  name: "options",
595
- children: `The options for the \`install\` function. Currently, there are no options available, but this parameter is included for future extensibility.`
714
+ children: `The options for the \`upgrade\` function. Currently, there are no options available, but this parameter is included for future extensibility.`
596
715
  }),
597
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocReturns, { children: `A promise that resolves when the installation of dependencies is complete.` })
716
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocReturns, { children: `A promise that resolves when the upgrade of dependencies is complete.` })
598
717
  ];
599
718
  }
600
719
  }),
601
720
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
602
721
  "export": true,
603
722
  async: true,
604
- name: "install",
723
+ name: "upgrade",
605
724
  parameters: [{
606
725
  name: "options",
607
- type: "InstallOptions",
726
+ type: "UpgradeOptions",
608
727
  default: "{}"
609
728
  }],
610
- returnType: "Promise<string>",
611
729
  get children() {
612
730
  return [
613
731
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
614
732
  "const": true,
615
733
  name: "packageManager",
616
- initializer: __alloy_js_core.code`getPackageManager(); `
734
+ initializer: __alloy_js_core.code`await getPackageManager(options); `
735
+ }),
736
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
737
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
738
+ "const": true,
739
+ name: "args",
740
+ initializer: __alloy_js_core.code`await getUpgradeCommand(packageManager, options.cwd); `
617
741
  }),
618
742
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
619
743
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
@@ -622,39 +746,165 @@ function InstallFunctionDeclaration() {
622
746
  initializer: __alloy_js_core.code`""; `
623
747
  }),
624
748
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
625
- __alloy_js_core.code`try {
626
- // await spawn(
627
- // \`\${packageManager}\${isWindows && packageManager !== "bun" ? ".cmd" : ""}\`,
628
- // ["install"],
629
- // {
630
- // stdout: (data: string) => {
631
- // options.stdout?.(data);
632
- // output += data;
633
- // },
634
- // stderr: (data: string) => {
635
- // options.stderr?.(data);
636
- // },
637
- // },
638
- // {
639
- // cwd: options.cwd ?? process.cwd(),
640
- // env: {
641
- // ...process.env,
642
- // ...(options.color !== false ? { FORCE_COLOR: true } : null),
643
- // // With spawn, pnpm install will fail with ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies.
644
- // // When pnpm install is run directly from the terminal, this error does not occur.
645
- // // When pnpm install is run from a simple spawn script, this error does not occur.
646
- // // The issue only seems to be when pnpm install is executed from npm-check-updates, but it's not clear what configuration or environmental factors are causing this.
647
- // // For now, turn off strict-peer-dependencies on pnpm auto-install.
648
- // // See: https://github.com/raineorshine/npm-check-updates/issues/1191
649
- // ...(packageManager === 'pnpm' ? { npm_config_strict_peer_dependencies: false } : null),
650
- // },
651
- // },
652
- // );
653
- } catch (err) {
654
- console.error("Error executing install command:", err);
655
- throw err;
656
- }
657
- `
749
+ __alloy_js_core.code`await spawn(
750
+ \`\${packageManager}\${isWindows && packageManager !== "bun" ? ".cmd" : ""}\`,
751
+ [args.join(" ")],
752
+ {
753
+ ...options,
754
+ env: {
755
+ ...options.env,
756
+ ...(packageManager === "pnpm" ? { npm_config_strict_peer_dependencies: false } : null),
757
+ },
758
+ stdout: (data: string) => {
759
+ options.stdout?.(data);
760
+ output += data;
761
+ },
762
+ stderr: (data: string) => {
763
+ options.stderr?.(data);
764
+ },
765
+ },
766
+ ); `
767
+ ];
768
+ }
769
+ })
770
+ ];
771
+ }
772
+ /**
773
+ * The `checkForUpdates` handler function declaration code for the Shell Shock project.
774
+ */
775
+ function CheckForUpdatesFunctionDeclaration() {
776
+ const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
777
+ return [
778
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
779
+ "export": true,
780
+ name: "CheckForUpdatesOptions",
781
+ "extends": "GetPackageManagerOptions",
782
+ doc: "Options for the `checkForUpdates` handler function."
783
+ }),
784
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
785
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
786
+ "export": true,
787
+ name: "CheckForUpdatesResult",
788
+ doc: "The result for the `checkForUpdates` handler function.",
789
+ get children() {
790
+ return [
791
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
792
+ name: "latestVersion",
793
+ type: "string",
794
+ doc: "The latest version of the application dependencies."
795
+ }),
796
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
797
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
798
+ name: "currentVersion",
799
+ type: "string",
800
+ doc: "The current version of the application dependencies."
801
+ }),
802
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
803
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
804
+ name: "isUpToDate",
805
+ type: "boolean",
806
+ doc: "Indicates whether the application dependencies are up-to-date."
807
+ }),
808
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
809
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
810
+ name: "package",
811
+ type: "NpmPackage",
812
+ doc: "The npm package that was checked for updates."
813
+ }),
814
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
815
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
816
+ name: "packageManager",
817
+ type: "'npm' | 'yarn' | 'pnpm' | 'deno' | 'bun'",
818
+ doc: "The package manager used to check for updates."
819
+ })
820
+ ];
821
+ }
822
+ }),
823
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
824
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDoc, {
825
+ heading: "Check for updates to the application dependencies.",
826
+ get children() {
827
+ return [
828
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocRemarks, { children: `This function is used to check for updates to the application dependencies. It can be used in the CLI upgrade command to ensure that all necessary dependencies are up-to-date.` }),
829
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
830
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocParam, {
831
+ name: "options",
832
+ children: `The options for the \`checkForUpdates\` function. Currently, there are no options available, but this parameter is included for future extensibility.`
833
+ }),
834
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocReturns, { children: `A promise that resolves when the check for updates is complete or undefined if the check was not performed.` })
835
+ ];
836
+ }
837
+ }),
838
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
839
+ "export": true,
840
+ async: true,
841
+ name: "checkForUpdates",
842
+ parameters: [{
843
+ name: "options",
844
+ type: "CheckForUpdatesOptions",
845
+ default: "{}"
846
+ }],
847
+ returnType: "Promise<CheckForUpdatesResult | undefined>",
848
+ get children() {
849
+ return [
850
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
851
+ "const": true,
852
+ name: "filePath",
853
+ initializer: __alloy_js_core.code`join(paths.data, "version-check.json"); `
854
+ }),
855
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
856
+ condition: __alloy_js_core.code`existsSync(filePath)`,
857
+ get children() {
858
+ return [
859
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
860
+ "const": true,
861
+ name: "file",
862
+ type: "{ timestamp: number; }",
863
+ initializer: __alloy_js_core.code` JSON.parse(await readFile(filePath, "utf8")); `
864
+ }),
865
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
866
+ condition: __alloy_js_core.code`!file.timestamp`,
867
+ children: __alloy_js_core.code`await writeFile(filePath, JSON.stringify({ timestamp: new Date().getTime() }), "utf8");
868
+ return undefined; `
869
+ }),
870
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
871
+ get condition() {
872
+ return __alloy_js_core.code`new Date().getTime() - file.timestamp < ${context.config.upgrade.staleTime}`;
873
+ },
874
+ children: __alloy_js_core.code`return undefined; `
875
+ })
876
+ ];
877
+ }
878
+ }),
879
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`await writeFile(filePath, JSON.stringify({ timestamp: new Date().getTime() }), "utf8");
880
+ return undefined; ` }),
881
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
882
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
883
+ "const": true,
884
+ name: "packageManager",
885
+ initializer: __alloy_js_core.code`await getPackageManager(options); `
886
+ }),
887
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
888
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
889
+ "const": true,
890
+ name: "pkg",
891
+ initializer: __alloy_js_core.code`await fetchNpmPackage(); `
892
+ }),
893
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
894
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
895
+ condition: __alloy_js_core.code`!pkg`,
896
+ children: __alloy_js_core.code`return undefined; `
897
+ }),
898
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
899
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`await writeFile(filePath, JSON.stringify({ timestamp: new Date().getTime() }), "utf8");
900
+
901
+ return {
902
+ latestVersion: pkg?.version ?? "0.0.0",
903
+ currentVersion: "${context.packageJson.version}",
904
+ isUpToDate: pkg ? "${context.packageJson.version}" === pkg.version : true,
905
+ package: pkg,
906
+ packageManager,
907
+ }; `)
658
908
  ];
659
909
  }
660
910
  })
@@ -685,7 +935,8 @@ function UpgradeBuiltin(props) {
685
935
  "verbose",
686
936
  "writeLine"
687
937
  ],
688
- env: ["paths", "isWindows"]
938
+ env: ["paths", "isWindows"],
939
+ utils: ["isColorSupported", "spawn"]
689
940
  });
690
941
  },
691
942
  get children() {
@@ -704,15 +955,21 @@ function UpgradeBuiltin(props) {
704
955
  initializer: __alloy_js_core.code`os.tmpdir(); `
705
956
  }),
706
957
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
958
+ (0, __alloy_js_core_jsx_runtime.createComponent)(LocatePackageJsonFunctionDeclaration, {}),
959
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
707
960
  (0, __alloy_js_core_jsx_runtime.createComponent)(LocateLockfileFunctionDeclaration, {}),
708
961
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
709
962
  (0, __alloy_js_core_jsx_runtime.createComponent)(GetPackageManagerFunctionDeclaration, {}),
710
963
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
711
964
  (0, __alloy_js_core_jsx_runtime.createComponent)(FetchNpmPackageFunctionDeclaration, {}),
712
965
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
713
- (0, __alloy_js_core_jsx_runtime.createComponent)(GetLatestFunctionDeclaration, {}),
966
+ (0, __alloy_js_core_jsx_runtime.createComponent)(GetLatestVersionFunctionDeclaration, {}),
967
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
968
+ (0, __alloy_js_core_jsx_runtime.createComponent)(GetUpgradeCommandFunctionDeclaration, {}),
969
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
970
+ (0, __alloy_js_core_jsx_runtime.createComponent)(UpgradeFunctionDeclaration, {}),
714
971
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
715
- (0, __alloy_js_core_jsx_runtime.createComponent)(InstallFunctionDeclaration, {}),
972
+ (0, __alloy_js_core_jsx_runtime.createComponent)(CheckForUpdatesFunctionDeclaration, {}),
716
973
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
717
974
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
718
975
  get when() {
@@ -726,10 +983,12 @@ function UpgradeBuiltin(props) {
726
983
  }
727
984
 
728
985
  //#endregion
986
+ exports.CheckForUpdatesFunctionDeclaration = CheckForUpdatesFunctionDeclaration;
729
987
  exports.FetchNpmPackageFunctionDeclaration = FetchNpmPackageFunctionDeclaration;
730
- exports.GetLatestFunctionDeclaration = GetLatestFunctionDeclaration;
988
+ exports.GetLatestVersionFunctionDeclaration = GetLatestVersionFunctionDeclaration;
731
989
  exports.GetPackageManagerFunctionDeclaration = GetPackageManagerFunctionDeclaration;
732
- exports.InstallFunctionDeclaration = InstallFunctionDeclaration;
990
+ exports.GetUpgradeCommandFunctionDeclaration = GetUpgradeCommandFunctionDeclaration;
733
991
  exports.LocateLockfileFunctionDeclaration = LocateLockfileFunctionDeclaration;
734
992
  exports.LocatePackageJsonFunctionDeclaration = LocatePackageJsonFunctionDeclaration;
735
- exports.UpgradeBuiltin = UpgradeBuiltin;
993
+ exports.UpgradeBuiltin = UpgradeBuiltin;
994
+ exports.UpgradeFunctionDeclaration = UpgradeFunctionDeclaration;