@shell-shock/plugin-upgrade 0.1.4 → 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,45 +572,124 @@ 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
- name: "InstallBaseOptions",
559
- doc: "Options for the `install` handler function.",
678
+ name: "UpgradeBaseOptions",
679
+ doc: "Options for the `upgrade` handler function.",
560
680
  get children() {
561
681
  return [
562
682
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
563
683
  name: "stdout",
564
684
  optional: true,
565
- type: "(string) => void",
685
+ type: "(data: string) => void",
566
686
  doc: "A callback function that is called with the stdout output of the command."
567
687
  }),
568
688
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
569
689
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
570
690
  name: "stderr",
571
691
  optional: true,
572
- type: "(string) => void",
692
+ type: "(err: string) => void",
573
693
  doc: "A callback function that is called with the stderr output of the command."
574
694
  })
575
695
  ];
@@ -578,32 +698,32 @@ function InstallFunctionDeclaration() {
578
698
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
579
699
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TypeDeclaration, {
580
700
  "export": true,
581
- name: "InstallOptions",
582
- doc: "Options for the `install` handler function.",
583
- children: __alloy_js_core.code`InstallBaseOptions & Parameters<typeof spawn>[2];`
701
+ name: "UpgradeOptions",
702
+ doc: "Options for the `upgrade` handler function.",
703
+ children: __alloy_js_core.code`UpgradeBaseOptions & GetPackageManagerOptions & Parameters<typeof spawn>[2];`
584
704
  }),
585
705
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
586
706
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDoc, {
587
- heading: "Install the application dependencies.",
707
+ heading: "Upgrade the application dependencies.",
588
708
  get children() {
589
709
  return [
590
- (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.` }),
591
711
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
592
712
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TSDocParam, {
593
713
  name: "options",
594
- 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.`
595
715
  }),
596
- (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.` })
597
717
  ];
598
718
  }
599
719
  }),
600
720
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
601
721
  "export": true,
602
722
  async: true,
603
- name: "install",
723
+ name: "upgrade",
604
724
  parameters: [{
605
725
  name: "options",
606
- type: "InstallOptions",
726
+ type: "UpgradeOptions",
607
727
  default: "{}"
608
728
  }],
609
729
  get children() {
@@ -611,9 +731,15 @@ function InstallFunctionDeclaration() {
611
731
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
612
732
  "const": true,
613
733
  name: "packageManager",
614
- initializer: __alloy_js_core.code`getPackageManager(); `
734
+ initializer: __alloy_js_core.code`await getPackageManager(options); `
615
735
  }),
616
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); `
741
+ }),
742
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
617
743
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
618
744
  "let": true,
619
745
  name: "output",
@@ -622,9 +748,9 @@ function InstallFunctionDeclaration() {
622
748
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
623
749
  __alloy_js_core.code`await spawn(
624
750
  \`\${packageManager}\${isWindows && packageManager !== "bun" ? ".cmd" : ""}\`,
625
- ["install"],
751
+ [args.join(" ")],
626
752
  {
627
- ...options
753
+ ...options,
628
754
  env: {
629
755
  ...options.env,
630
756
  ...(packageManager === "pnpm" ? { npm_config_strict_peer_dependencies: false } : null),
@@ -644,6 +770,147 @@ function InstallFunctionDeclaration() {
644
770
  ];
645
771
  }
646
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
+ }; `)
908
+ ];
909
+ }
910
+ })
911
+ ];
912
+ }
913
+ /**
647
914
  * A built-in upgrade module for Shell Shock.
648
915
  */
649
916
  function UpgradeBuiltin(props) {
@@ -688,15 +955,21 @@ function UpgradeBuiltin(props) {
688
955
  initializer: __alloy_js_core.code`os.tmpdir(); `
689
956
  }),
690
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, {}),
691
960
  (0, __alloy_js_core_jsx_runtime.createComponent)(LocateLockfileFunctionDeclaration, {}),
692
961
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
693
962
  (0, __alloy_js_core_jsx_runtime.createComponent)(GetPackageManagerFunctionDeclaration, {}),
694
963
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
695
964
  (0, __alloy_js_core_jsx_runtime.createComponent)(FetchNpmPackageFunctionDeclaration, {}),
696
965
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
697
- (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, {}),
698
971
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
699
- (0, __alloy_js_core_jsx_runtime.createComponent)(InstallFunctionDeclaration, {}),
972
+ (0, __alloy_js_core_jsx_runtime.createComponent)(CheckForUpdatesFunctionDeclaration, {}),
700
973
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
701
974
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
702
975
  get when() {
@@ -710,10 +983,12 @@ function UpgradeBuiltin(props) {
710
983
  }
711
984
 
712
985
  //#endregion
986
+ exports.CheckForUpdatesFunctionDeclaration = CheckForUpdatesFunctionDeclaration;
713
987
  exports.FetchNpmPackageFunctionDeclaration = FetchNpmPackageFunctionDeclaration;
714
- exports.GetLatestFunctionDeclaration = GetLatestFunctionDeclaration;
988
+ exports.GetLatestVersionFunctionDeclaration = GetLatestVersionFunctionDeclaration;
715
989
  exports.GetPackageManagerFunctionDeclaration = GetPackageManagerFunctionDeclaration;
716
- exports.InstallFunctionDeclaration = InstallFunctionDeclaration;
990
+ exports.GetUpgradeCommandFunctionDeclaration = GetUpgradeCommandFunctionDeclaration;
717
991
  exports.LocateLockfileFunctionDeclaration = LocateLockfileFunctionDeclaration;
718
992
  exports.LocatePackageJsonFunctionDeclaration = LocatePackageJsonFunctionDeclaration;
719
- exports.UpgradeBuiltin = UpgradeBuiltin;
993
+ exports.UpgradeBuiltin = UpgradeBuiltin;
994
+ exports.UpgradeFunctionDeclaration = UpgradeFunctionDeclaration;
@@ -19,18 +19,26 @@ declare function GetPackageManagerFunctionDeclaration(): _alloy_js_core0.Childre
19
19
  */
20
20
  declare function FetchNpmPackageFunctionDeclaration(): _alloy_js_core0.Children;
21
21
  /**
22
- * The `getLatest` handler function declaration code for the Shell Shock project.
22
+ * The `getLatestVersion` handler function declaration code for the Shell Shock project.
23
23
  */
24
- declare function GetLatestFunctionDeclaration(): _alloy_js_core0.Children;
24
+ declare function GetLatestVersionFunctionDeclaration(): _alloy_js_core0.Children;
25
25
  /**
26
- * The `install` handler function declaration code for the Shell Shock project.
26
+ * The `upgrade` handler function declaration code for the Shell Shock project.
27
27
  */
28
- declare function InstallFunctionDeclaration(): _alloy_js_core0.Children;
28
+ declare function GetUpgradeCommandFunctionDeclaration(): _alloy_js_core0.Children;
29
+ /**
30
+ * The `upgrade` handler function declaration code for the Shell Shock project.
31
+ */
32
+ declare function UpgradeFunctionDeclaration(): _alloy_js_core0.Children;
33
+ /**
34
+ * The `checkForUpdates` handler function declaration code for the Shell Shock project.
35
+ */
36
+ declare function CheckForUpdatesFunctionDeclaration(): _alloy_js_core0.Children;
29
37
  interface UpgradeBuiltinProps extends Omit<BuiltinFileProps, "id" | "description"> {}
30
38
  /**
31
39
  * A built-in upgrade module for Shell Shock.
32
40
  */
33
41
  declare function UpgradeBuiltin(props: UpgradeBuiltinProps): _alloy_js_core0.Children;
34
42
  //#endregion
35
- export { FetchNpmPackageFunctionDeclaration, GetLatestFunctionDeclaration, GetPackageManagerFunctionDeclaration, InstallFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps };
43
+ export { CheckForUpdatesFunctionDeclaration, FetchNpmPackageFunctionDeclaration, GetLatestVersionFunctionDeclaration, GetPackageManagerFunctionDeclaration, GetUpgradeCommandFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps, UpgradeFunctionDeclaration };
36
44
  //# sourceMappingURL=upgrade-builtin.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade-builtin.d.cts","names":[],"sources":["../../src/components/upgrade-builtin.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA2CgB,iBAAA,oCAAA,CAAA,CAAoC,EAAA,eAAA,CAAA,QAAA;AAwEpD;AAwFA;AAyIA;AA6KgB,iBA9YA,iCAAA,CAAA,CA8Y4B,EA9YK,eAAA,CAAA,QA8YL;AAwC5C;AAgFA;AAQA;iBAtbgB,oCAAA,CAAA,GAAoC,eAAA,CAAA;;;;iBAyIpC,kCAAA,CAAA,GAAkC,eAAA,CAAA;;;;iBA6KlC,4BAAA,CAAA,GAA4B,eAAA,CAAA;;;;iBAwC5B,0BAAA,CAAA,GAA0B,eAAA,CAAA;UAgFzB,mBAAA,SAA4B,KAC3C;;;;iBAOc,cAAA,QAAsB,sBAAmB,eAAA,CAAA"}
1
+ {"version":3,"file":"upgrade-builtin.d.cts","names":[],"sources":["../../src/components/upgrade-builtin.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA6CgB,iBAAA,oCAAA,CAAA,CAAoC,EAAA,eAAA,CAAA,QAAA;AAgGpD;AAuFA;AAkJA;AA6KgB,iBAtZA,iCAAA,CAAA,CAsZmC,EAtZF,eAAA,CAAA,QAsZE;AA2CnD;AAyEA;AAyFA;AAgIiB,iBA5oBD,oCAAA,CAAA,CA4oBiC,EA5oBG,eAAA,CAAA,QA4oBH;AAQjD;;;iBAlgBgB,kCAAA,CAAA,GAAkC,eAAA,CAAA;;;;iBA6KlC,mCAAA,CAAA,GAAmC,eAAA,CAAA;;;;iBA2CnC,oCAAA,CAAA,GAAoC,eAAA,CAAA;;;;iBAyEpC,0BAAA,CAAA,GAA0B,eAAA,CAAA;;;;iBAyF1B,kCAAA,CAAA,GAAkC,eAAA,CAAA;UAgIjC,mBAAA,SAA4B,KAC3C;;;;iBAOc,cAAA,QAAsB,sBAAmB,eAAA,CAAA"}