@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.
- package/dist/components/index.cjs +5 -3
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +2 -2
- package/dist/components/upgrade-builtin.cjs +320 -45
- package/dist/components/upgrade-builtin.d.cts +13 -5
- package/dist/components/upgrade-builtin.d.cts.map +1 -1
- package/dist/components/upgrade-builtin.d.mts +13 -5
- package/dist/components/upgrade-builtin.d.mts.map +1 -1
- package/dist/components/upgrade-builtin.mjs +316 -43
- package/dist/components/upgrade-builtin.mjs.map +1 -1
- package/dist/components/upgrade-command.cjs +1 -1
- package/dist/components/upgrade-command.d.cts +2 -2
- package/dist/components/upgrade-command.mjs +1 -1
- package/dist/index.cjs +6 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/package-manager.d.cts.map +1 -1
- package/dist/types/plugin.d.cts +21 -5
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +21 -5
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +3 -3
|
@@ -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 `
|
|
22
|
+
* The `getLatestVersion` handler function declaration code for the Shell Shock project.
|
|
23
23
|
*/
|
|
24
|
-
declare function
|
|
24
|
+
declare function GetLatestVersionFunctionDeclaration(): _alloy_js_core0.Children;
|
|
25
25
|
/**
|
|
26
|
-
* The `
|
|
26
|
+
* The `upgrade` handler function declaration code for the Shell Shock project.
|
|
27
27
|
*/
|
|
28
|
-
declare function
|
|
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,
|
|
43
|
+
export { CheckForUpdatesFunctionDeclaration, FetchNpmPackageFunctionDeclaration, GetLatestVersionFunctionDeclaration, GetPackageManagerFunctionDeclaration, GetUpgradeCommandFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeBuiltinProps, UpgradeFunctionDeclaration };
|
|
36
44
|
//# sourceMappingURL=upgrade-builtin.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-builtin.d.mts","names":[],"sources":["../../src/components/upgrade-builtin.tsx"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"upgrade-builtin.d.mts","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"}
|
|
@@ -1,28 +1,39 @@
|
|
|
1
|
-
import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import defu from "defu";
|
|
2
3
|
import { Show, code, splitProps } from "@alloy-js/core";
|
|
3
4
|
import { ElseClause, ElseIfClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
4
5
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
6
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
5
7
|
import { InterfaceMember, TSDoc, TSDocParam, TSDocRemarks, TSDocReturns, TypeDeclaration } from "@powerlines/plugin-alloy/typescript";
|
|
6
8
|
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
7
|
-
import defu from "defu";
|
|
8
9
|
|
|
9
10
|
//#region src/components/upgrade-builtin.tsx
|
|
10
11
|
/**
|
|
11
12
|
* The `locatePackageJson` handler function declaration code for the Shell Shock project.
|
|
12
13
|
*/
|
|
13
14
|
function LocatePackageJsonFunctionDeclaration() {
|
|
15
|
+
const context = usePowerlines();
|
|
14
16
|
return [
|
|
15
17
|
createComponent(InterfaceDeclaration, {
|
|
16
18
|
"export": true,
|
|
17
19
|
name: "LocatePackageJsonOptions",
|
|
18
20
|
doc: "Options for the `locatePackageJson` handler function.",
|
|
19
21
|
get children() {
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
return [
|
|
23
|
+
createComponent(InterfaceMember, {
|
|
24
|
+
name: "cwd",
|
|
25
|
+
optional: true,
|
|
26
|
+
type: "string",
|
|
27
|
+
doc: "The current working directory to use. If not provided, the process's current working directory will be used."
|
|
28
|
+
}),
|
|
29
|
+
createComponent(Spacing, {}),
|
|
30
|
+
createComponent(InterfaceMember, {
|
|
31
|
+
name: "isDependencyRequired",
|
|
32
|
+
optional: true,
|
|
33
|
+
type: "boolean",
|
|
34
|
+
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."
|
|
35
|
+
})
|
|
36
|
+
];
|
|
26
37
|
}
|
|
27
38
|
}),
|
|
28
39
|
createComponent(Spacing, {}),
|
|
@@ -66,11 +77,32 @@ function LocatePackageJsonFunctionDeclaration() {
|
|
|
66
77
|
}),
|
|
67
78
|
createComponent(Spacing, {}),
|
|
68
79
|
code`while (parentPath !== currentPath && currentPath !== homePath && currentPath !== tempPath) { `,
|
|
69
|
-
createComponent(
|
|
70
|
-
|
|
71
|
-
|
|
80
|
+
createComponent(VarDeclaration, {
|
|
81
|
+
"const": true,
|
|
82
|
+
name: "packageJsonPath",
|
|
83
|
+
initializer: code`join(currentPath, "package.json"); `
|
|
72
84
|
}),
|
|
73
|
-
createComponent(
|
|
85
|
+
createComponent(IfStatement, {
|
|
86
|
+
condition: code`existsSync(packageJsonPath)`,
|
|
87
|
+
get children() {
|
|
88
|
+
return [createComponent(IfStatement, {
|
|
89
|
+
condition: code`options.isDependencyRequired`,
|
|
90
|
+
get children() {
|
|
91
|
+
return [createComponent(VarDeclaration, {
|
|
92
|
+
"const": true,
|
|
93
|
+
name: "packageJson",
|
|
94
|
+
initializer: code`JSON.parse(await readFile(packageJsonPath, "utf8")); `
|
|
95
|
+
}), createComponent(IfStatement, {
|
|
96
|
+
get condition() {
|
|
97
|
+
return 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}@"))`;
|
|
98
|
+
},
|
|
99
|
+
children: code`return packageJsonPath; `
|
|
100
|
+
})];
|
|
101
|
+
}
|
|
102
|
+
}), createComponent(ElseClause, { children: code`return packageJsonPath; ` })];
|
|
103
|
+
}
|
|
104
|
+
}),
|
|
105
|
+
createComponent(ElseClause, { children: code`currentPath = parentPath;
|
|
74
106
|
parentPath = resolve(currentPath, ".."); ` }),
|
|
75
107
|
code` }
|
|
76
108
|
|
|
@@ -115,7 +147,6 @@ function LocateLockfileFunctionDeclaration() {
|
|
|
115
147
|
}),
|
|
116
148
|
createComponent(FunctionDeclaration, {
|
|
117
149
|
"export": true,
|
|
118
|
-
async: true,
|
|
119
150
|
name: "locateLockfile",
|
|
120
151
|
parameters: [{
|
|
121
152
|
name: "options",
|
|
@@ -160,7 +191,7 @@ function LocateLockfileFunctionDeclaration() {
|
|
|
160
191
|
condition: code`lockfile`,
|
|
161
192
|
children: code`return lockfile; `
|
|
162
193
|
}),
|
|
163
|
-
createComponent(ElseClause, { children: code`currentPath =
|
|
194
|
+
createComponent(ElseClause, { children: code`currentPath = parentPath;
|
|
164
195
|
parentPath = resolve(currentPath, ".."); ` }),
|
|
165
196
|
code` }
|
|
166
197
|
|
|
@@ -175,6 +206,15 @@ function LocateLockfileFunctionDeclaration() {
|
|
|
175
206
|
*/
|
|
176
207
|
function GetPackageManagerFunctionDeclaration() {
|
|
177
208
|
return [
|
|
209
|
+
code`declare global {
|
|
210
|
+
var Bun: any;
|
|
211
|
+
namespace NodeJS {
|
|
212
|
+
interface ProcessVersions {
|
|
213
|
+
bun?: string;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} `,
|
|
217
|
+
createComponent(Spacing, {}),
|
|
178
218
|
createComponent(TypeDeclaration, {
|
|
179
219
|
"export": true,
|
|
180
220
|
name: "GetPackageManagerOptions",
|
|
@@ -263,7 +303,7 @@ function GetPackageManagerFunctionDeclaration() {
|
|
|
263
303
|
createComponent(VarDeclaration, {
|
|
264
304
|
"const": true,
|
|
265
305
|
name: "packageJsonPath",
|
|
266
|
-
initializer: code`locatePackageJson(options); `
|
|
306
|
+
initializer: code`await locatePackageJson(options); `
|
|
267
307
|
}),
|
|
268
308
|
createComponent(IfStatement, {
|
|
269
309
|
condition: code`packageJsonPath && existsSync(packageJsonPath)`,
|
|
@@ -510,9 +550,10 @@ function FetchNpmPackageFunctionDeclaration() {
|
|
|
510
550
|
];
|
|
511
551
|
}
|
|
512
552
|
/**
|
|
513
|
-
* The `
|
|
553
|
+
* The `getLatestVersion` handler function declaration code for the Shell Shock project.
|
|
514
554
|
*/
|
|
515
|
-
function
|
|
555
|
+
function GetLatestVersionFunctionDeclaration() {
|
|
556
|
+
const context = usePowerlines();
|
|
516
557
|
return [createComponent(TSDoc, {
|
|
517
558
|
heading: "Get the latest version of the application from the npm registry.",
|
|
518
559
|
get children() {
|
|
@@ -529,45 +570,124 @@ function GetLatestFunctionDeclaration() {
|
|
|
529
570
|
}), createComponent(FunctionDeclaration, {
|
|
530
571
|
"export": true,
|
|
531
572
|
async: true,
|
|
532
|
-
name: "
|
|
573
|
+
name: "getLatestVersion",
|
|
574
|
+
get parameters() {
|
|
575
|
+
return [{
|
|
576
|
+
name: "packageName",
|
|
577
|
+
default: `"${context.packageJson.name}"`
|
|
578
|
+
}];
|
|
579
|
+
},
|
|
580
|
+
returnType: code`Promise<string | undefined>`,
|
|
581
|
+
get children() {
|
|
582
|
+
return [
|
|
583
|
+
createComponent(VarDeclaration, {
|
|
584
|
+
"const": true,
|
|
585
|
+
name: "result",
|
|
586
|
+
initializer: code`await fetchNpmPackage(packageName); `
|
|
587
|
+
}),
|
|
588
|
+
createComponent(Spacing, {}),
|
|
589
|
+
code`return result?.version; `
|
|
590
|
+
];
|
|
591
|
+
}
|
|
592
|
+
})];
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* The `upgrade` handler function declaration code for the Shell Shock project.
|
|
596
|
+
*/
|
|
597
|
+
function GetUpgradeCommandFunctionDeclaration() {
|
|
598
|
+
const context = usePowerlines();
|
|
599
|
+
return [createComponent(TSDoc, {
|
|
600
|
+
heading: "A function to get the upgrade command for a specific package manager.",
|
|
601
|
+
get children() {
|
|
602
|
+
return [
|
|
603
|
+
createComponent(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.` }),
|
|
604
|
+
createComponent(Spacing, {}),
|
|
605
|
+
createComponent(TSDocParam, {
|
|
606
|
+
name: "packageManager",
|
|
607
|
+
children: `The name of the package manager to get the upgrade command for. This should be one of "npm", "yarn", "pnpm", "deno", or "bun".`
|
|
608
|
+
}),
|
|
609
|
+
createComponent(TSDocParam, {
|
|
610
|
+
name: "cwd",
|
|
611
|
+
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.`
|
|
612
|
+
}),
|
|
613
|
+
createComponent(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.` })
|
|
614
|
+
];
|
|
615
|
+
}
|
|
616
|
+
}), createComponent(FunctionDeclaration, {
|
|
617
|
+
"export": true,
|
|
618
|
+
async: true,
|
|
619
|
+
name: "getUpgradeCommand",
|
|
533
620
|
parameters: [{
|
|
534
|
-
name: "
|
|
621
|
+
name: "packageManager",
|
|
535
622
|
type: "string"
|
|
623
|
+
}, {
|
|
624
|
+
name: "cwd",
|
|
625
|
+
type: "string",
|
|
626
|
+
default: "process.cwd()"
|
|
536
627
|
}],
|
|
628
|
+
returnType: "Promise<string[]>",
|
|
537
629
|
get children() {
|
|
538
630
|
return [
|
|
539
631
|
createComponent(VarDeclaration, {
|
|
540
632
|
"const": true,
|
|
541
|
-
name: "
|
|
542
|
-
initializer
|
|
633
|
+
name: "version",
|
|
634
|
+
get initializer() {
|
|
635
|
+
return code`(await getLatestVersion("${context.packageJson.name}")) || "latest"; `;
|
|
636
|
+
}
|
|
543
637
|
}),
|
|
544
638
|
createComponent(Spacing, {}),
|
|
545
|
-
|
|
639
|
+
createComponent(IfStatement, {
|
|
640
|
+
condition: code`packageManager === "yarn"`,
|
|
641
|
+
get children() {
|
|
642
|
+
return code`return ["upgrade", \`${context.packageJson.name}@\${version}\`]; `;
|
|
643
|
+
}
|
|
644
|
+
}),
|
|
645
|
+
createComponent(ElseIfClause, {
|
|
646
|
+
condition: code`packageManager === "pnpm"`,
|
|
647
|
+
get children() {
|
|
648
|
+
return code`return ["update", \`${context.packageJson.name}@\${version}\`]; `;
|
|
649
|
+
}
|
|
650
|
+
}),
|
|
651
|
+
createComponent(ElseIfClause, {
|
|
652
|
+
condition: code`packageManager === "deno"`,
|
|
653
|
+
get children() {
|
|
654
|
+
return code`return ["outdated", "--update", \`${context.packageJson.name}@\${version}\`]; `;
|
|
655
|
+
}
|
|
656
|
+
}),
|
|
657
|
+
createComponent(ElseIfClause, {
|
|
658
|
+
condition: code`packageManager === "bun"`,
|
|
659
|
+
get children() {
|
|
660
|
+
return code`return ["update", "--save", \`${context.packageJson.name}@\${version}\`]; `;
|
|
661
|
+
}
|
|
662
|
+
}),
|
|
663
|
+
createComponent(ElseClause, { get children() {
|
|
664
|
+
return code`return ["update", "--save", "--bin-links", \`${context.packageJson.name}@\${version}\`]; `;
|
|
665
|
+
} })
|
|
546
666
|
];
|
|
547
667
|
}
|
|
548
668
|
})];
|
|
549
669
|
}
|
|
550
670
|
/**
|
|
551
|
-
* The `
|
|
671
|
+
* The `upgrade` handler function declaration code for the Shell Shock project.
|
|
552
672
|
*/
|
|
553
|
-
function
|
|
673
|
+
function UpgradeFunctionDeclaration() {
|
|
554
674
|
return [
|
|
555
675
|
createComponent(InterfaceDeclaration, {
|
|
556
|
-
name: "
|
|
557
|
-
doc: "Options for the `
|
|
676
|
+
name: "UpgradeBaseOptions",
|
|
677
|
+
doc: "Options for the `upgrade` handler function.",
|
|
558
678
|
get children() {
|
|
559
679
|
return [
|
|
560
680
|
createComponent(InterfaceMember, {
|
|
561
681
|
name: "stdout",
|
|
562
682
|
optional: true,
|
|
563
|
-
type: "(string) => void",
|
|
683
|
+
type: "(data: string) => void",
|
|
564
684
|
doc: "A callback function that is called with the stdout output of the command."
|
|
565
685
|
}),
|
|
566
686
|
createIntrinsic("hbr", {}),
|
|
567
687
|
createComponent(InterfaceMember, {
|
|
568
688
|
name: "stderr",
|
|
569
689
|
optional: true,
|
|
570
|
-
type: "(string) => void",
|
|
690
|
+
type: "(err: string) => void",
|
|
571
691
|
doc: "A callback function that is called with the stderr output of the command."
|
|
572
692
|
})
|
|
573
693
|
];
|
|
@@ -576,32 +696,32 @@ function InstallFunctionDeclaration() {
|
|
|
576
696
|
createComponent(Spacing, {}),
|
|
577
697
|
createComponent(TypeDeclaration, {
|
|
578
698
|
"export": true,
|
|
579
|
-
name: "
|
|
580
|
-
doc: "Options for the `
|
|
581
|
-
children: code`
|
|
699
|
+
name: "UpgradeOptions",
|
|
700
|
+
doc: "Options for the `upgrade` handler function.",
|
|
701
|
+
children: code`UpgradeBaseOptions & GetPackageManagerOptions & Parameters<typeof spawn>[2];`
|
|
582
702
|
}),
|
|
583
703
|
createComponent(Spacing, {}),
|
|
584
704
|
createComponent(TSDoc, {
|
|
585
|
-
heading: "
|
|
705
|
+
heading: "Upgrade the application dependencies.",
|
|
586
706
|
get children() {
|
|
587
707
|
return [
|
|
588
|
-
createComponent(TSDocRemarks, { children: `This function is used to
|
|
708
|
+
createComponent(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.` }),
|
|
589
709
|
createComponent(Spacing, {}),
|
|
590
710
|
createComponent(TSDocParam, {
|
|
591
711
|
name: "options",
|
|
592
|
-
children: `The options for the \`
|
|
712
|
+
children: `The options for the \`upgrade\` function. Currently, there are no options available, but this parameter is included for future extensibility.`
|
|
593
713
|
}),
|
|
594
|
-
createComponent(TSDocReturns, { children: `A promise that resolves when the
|
|
714
|
+
createComponent(TSDocReturns, { children: `A promise that resolves when the upgrade of dependencies is complete.` })
|
|
595
715
|
];
|
|
596
716
|
}
|
|
597
717
|
}),
|
|
598
718
|
createComponent(FunctionDeclaration, {
|
|
599
719
|
"export": true,
|
|
600
720
|
async: true,
|
|
601
|
-
name: "
|
|
721
|
+
name: "upgrade",
|
|
602
722
|
parameters: [{
|
|
603
723
|
name: "options",
|
|
604
|
-
type: "
|
|
724
|
+
type: "UpgradeOptions",
|
|
605
725
|
default: "{}"
|
|
606
726
|
}],
|
|
607
727
|
get children() {
|
|
@@ -609,9 +729,15 @@ function InstallFunctionDeclaration() {
|
|
|
609
729
|
createComponent(VarDeclaration, {
|
|
610
730
|
"const": true,
|
|
611
731
|
name: "packageManager",
|
|
612
|
-
initializer: code`getPackageManager(); `
|
|
732
|
+
initializer: code`await getPackageManager(options); `
|
|
613
733
|
}),
|
|
614
734
|
createComponent(Spacing, {}),
|
|
735
|
+
createComponent(VarDeclaration, {
|
|
736
|
+
"const": true,
|
|
737
|
+
name: "args",
|
|
738
|
+
initializer: code`await getUpgradeCommand(packageManager, options.cwd); `
|
|
739
|
+
}),
|
|
740
|
+
createIntrinsic("hbr", {}),
|
|
615
741
|
createComponent(VarDeclaration, {
|
|
616
742
|
"let": true,
|
|
617
743
|
name: "output",
|
|
@@ -620,9 +746,9 @@ function InstallFunctionDeclaration() {
|
|
|
620
746
|
createIntrinsic("hbr", {}),
|
|
621
747
|
code`await spawn(
|
|
622
748
|
\`\${packageManager}\${isWindows && packageManager !== "bun" ? ".cmd" : ""}\`,
|
|
623
|
-
["
|
|
749
|
+
[args.join(" ")],
|
|
624
750
|
{
|
|
625
|
-
...options
|
|
751
|
+
...options,
|
|
626
752
|
env: {
|
|
627
753
|
...options.env,
|
|
628
754
|
...(packageManager === "pnpm" ? { npm_config_strict_peer_dependencies: false } : null),
|
|
@@ -642,6 +768,147 @@ function InstallFunctionDeclaration() {
|
|
|
642
768
|
];
|
|
643
769
|
}
|
|
644
770
|
/**
|
|
771
|
+
* The `checkForUpdates` handler function declaration code for the Shell Shock project.
|
|
772
|
+
*/
|
|
773
|
+
function CheckForUpdatesFunctionDeclaration() {
|
|
774
|
+
const context = usePowerlines();
|
|
775
|
+
return [
|
|
776
|
+
createComponent(InterfaceDeclaration, {
|
|
777
|
+
"export": true,
|
|
778
|
+
name: "CheckForUpdatesOptions",
|
|
779
|
+
"extends": "GetPackageManagerOptions",
|
|
780
|
+
doc: "Options for the `checkForUpdates` handler function."
|
|
781
|
+
}),
|
|
782
|
+
createComponent(Spacing, {}),
|
|
783
|
+
createComponent(InterfaceDeclaration, {
|
|
784
|
+
"export": true,
|
|
785
|
+
name: "CheckForUpdatesResult",
|
|
786
|
+
doc: "The result for the `checkForUpdates` handler function.",
|
|
787
|
+
get children() {
|
|
788
|
+
return [
|
|
789
|
+
createComponent(InterfaceMember, {
|
|
790
|
+
name: "latestVersion",
|
|
791
|
+
type: "string",
|
|
792
|
+
doc: "The latest version of the application dependencies."
|
|
793
|
+
}),
|
|
794
|
+
createIntrinsic("hbr", {}),
|
|
795
|
+
createComponent(InterfaceMember, {
|
|
796
|
+
name: "currentVersion",
|
|
797
|
+
type: "string",
|
|
798
|
+
doc: "The current version of the application dependencies."
|
|
799
|
+
}),
|
|
800
|
+
createIntrinsic("hbr", {}),
|
|
801
|
+
createComponent(InterfaceMember, {
|
|
802
|
+
name: "isUpToDate",
|
|
803
|
+
type: "boolean",
|
|
804
|
+
doc: "Indicates whether the application dependencies are up-to-date."
|
|
805
|
+
}),
|
|
806
|
+
createIntrinsic("hbr", {}),
|
|
807
|
+
createComponent(InterfaceMember, {
|
|
808
|
+
name: "package",
|
|
809
|
+
type: "NpmPackage",
|
|
810
|
+
doc: "The npm package that was checked for updates."
|
|
811
|
+
}),
|
|
812
|
+
createIntrinsic("hbr", {}),
|
|
813
|
+
createComponent(InterfaceMember, {
|
|
814
|
+
name: "packageManager",
|
|
815
|
+
type: "'npm' | 'yarn' | 'pnpm' | 'deno' | 'bun'",
|
|
816
|
+
doc: "The package manager used to check for updates."
|
|
817
|
+
})
|
|
818
|
+
];
|
|
819
|
+
}
|
|
820
|
+
}),
|
|
821
|
+
createComponent(Spacing, {}),
|
|
822
|
+
createComponent(TSDoc, {
|
|
823
|
+
heading: "Check for updates to the application dependencies.",
|
|
824
|
+
get children() {
|
|
825
|
+
return [
|
|
826
|
+
createComponent(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.` }),
|
|
827
|
+
createComponent(Spacing, {}),
|
|
828
|
+
createComponent(TSDocParam, {
|
|
829
|
+
name: "options",
|
|
830
|
+
children: `The options for the \`checkForUpdates\` function. Currently, there are no options available, but this parameter is included for future extensibility.`
|
|
831
|
+
}),
|
|
832
|
+
createComponent(TSDocReturns, { children: `A promise that resolves when the check for updates is complete or undefined if the check was not performed.` })
|
|
833
|
+
];
|
|
834
|
+
}
|
|
835
|
+
}),
|
|
836
|
+
createComponent(FunctionDeclaration, {
|
|
837
|
+
"export": true,
|
|
838
|
+
async: true,
|
|
839
|
+
name: "checkForUpdates",
|
|
840
|
+
parameters: [{
|
|
841
|
+
name: "options",
|
|
842
|
+
type: "CheckForUpdatesOptions",
|
|
843
|
+
default: "{}"
|
|
844
|
+
}],
|
|
845
|
+
returnType: "Promise<CheckForUpdatesResult | undefined>",
|
|
846
|
+
get children() {
|
|
847
|
+
return [
|
|
848
|
+
createComponent(VarDeclaration, {
|
|
849
|
+
"const": true,
|
|
850
|
+
name: "filePath",
|
|
851
|
+
initializer: code`join(paths.data, "version-check.json"); `
|
|
852
|
+
}),
|
|
853
|
+
createComponent(IfStatement, {
|
|
854
|
+
condition: code`existsSync(filePath)`,
|
|
855
|
+
get children() {
|
|
856
|
+
return [
|
|
857
|
+
createComponent(VarDeclaration, {
|
|
858
|
+
"const": true,
|
|
859
|
+
name: "file",
|
|
860
|
+
type: "{ timestamp: number; }",
|
|
861
|
+
initializer: code` JSON.parse(await readFile(filePath, "utf8")); `
|
|
862
|
+
}),
|
|
863
|
+
createComponent(IfStatement, {
|
|
864
|
+
condition: code`!file.timestamp`,
|
|
865
|
+
children: code`await writeFile(filePath, JSON.stringify({ timestamp: new Date().getTime() }), "utf8");
|
|
866
|
+
return undefined; `
|
|
867
|
+
}),
|
|
868
|
+
createComponent(ElseIfClause, {
|
|
869
|
+
get condition() {
|
|
870
|
+
return code`new Date().getTime() - file.timestamp < ${context.config.upgrade.staleTime}`;
|
|
871
|
+
},
|
|
872
|
+
children: code`return undefined; `
|
|
873
|
+
})
|
|
874
|
+
];
|
|
875
|
+
}
|
|
876
|
+
}),
|
|
877
|
+
createComponent(ElseClause, { children: code`await writeFile(filePath, JSON.stringify({ timestamp: new Date().getTime() }), "utf8");
|
|
878
|
+
return undefined; ` }),
|
|
879
|
+
createComponent(Spacing, {}),
|
|
880
|
+
createComponent(VarDeclaration, {
|
|
881
|
+
"const": true,
|
|
882
|
+
name: "packageManager",
|
|
883
|
+
initializer: code`await getPackageManager(options); `
|
|
884
|
+
}),
|
|
885
|
+
createComponent(Spacing, {}),
|
|
886
|
+
createComponent(VarDeclaration, {
|
|
887
|
+
"const": true,
|
|
888
|
+
name: "pkg",
|
|
889
|
+
initializer: code`await fetchNpmPackage(); `
|
|
890
|
+
}),
|
|
891
|
+
createComponent(Spacing, {}),
|
|
892
|
+
createComponent(IfStatement, {
|
|
893
|
+
condition: code`!pkg`,
|
|
894
|
+
children: code`return undefined; `
|
|
895
|
+
}),
|
|
896
|
+
createComponent(Spacing, {}),
|
|
897
|
+
memo(() => code`await writeFile(filePath, JSON.stringify({ timestamp: new Date().getTime() }), "utf8");
|
|
898
|
+
|
|
899
|
+
return {
|
|
900
|
+
latestVersion: pkg?.version ?? "0.0.0",
|
|
901
|
+
currentVersion: "${context.packageJson.version}",
|
|
902
|
+
isUpToDate: pkg ? "${context.packageJson.version}" === pkg.version : true,
|
|
903
|
+
package: pkg,
|
|
904
|
+
packageManager,
|
|
905
|
+
}; `)
|
|
906
|
+
];
|
|
907
|
+
}
|
|
908
|
+
})
|
|
909
|
+
];
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
645
912
|
* A built-in upgrade module for Shell Shock.
|
|
646
913
|
*/
|
|
647
914
|
function UpgradeBuiltin(props) {
|
|
@@ -686,15 +953,21 @@ function UpgradeBuiltin(props) {
|
|
|
686
953
|
initializer: code`os.tmpdir(); `
|
|
687
954
|
}),
|
|
688
955
|
createComponent(Spacing, {}),
|
|
956
|
+
createComponent(LocatePackageJsonFunctionDeclaration, {}),
|
|
957
|
+
createComponent(Spacing, {}),
|
|
689
958
|
createComponent(LocateLockfileFunctionDeclaration, {}),
|
|
690
959
|
createComponent(Spacing, {}),
|
|
691
960
|
createComponent(GetPackageManagerFunctionDeclaration, {}),
|
|
692
961
|
createComponent(Spacing, {}),
|
|
693
962
|
createComponent(FetchNpmPackageFunctionDeclaration, {}),
|
|
694
963
|
createComponent(Spacing, {}),
|
|
695
|
-
createComponent(
|
|
964
|
+
createComponent(GetLatestVersionFunctionDeclaration, {}),
|
|
965
|
+
createComponent(Spacing, {}),
|
|
966
|
+
createComponent(GetUpgradeCommandFunctionDeclaration, {}),
|
|
967
|
+
createComponent(Spacing, {}),
|
|
968
|
+
createComponent(UpgradeFunctionDeclaration, {}),
|
|
696
969
|
createComponent(Spacing, {}),
|
|
697
|
-
createComponent(
|
|
970
|
+
createComponent(CheckForUpdatesFunctionDeclaration, {}),
|
|
698
971
|
createComponent(Spacing, {}),
|
|
699
972
|
createComponent(Show, {
|
|
700
973
|
get when() {
|
|
@@ -708,5 +981,5 @@ function UpgradeBuiltin(props) {
|
|
|
708
981
|
}
|
|
709
982
|
|
|
710
983
|
//#endregion
|
|
711
|
-
export { FetchNpmPackageFunctionDeclaration,
|
|
984
|
+
export { CheckForUpdatesFunctionDeclaration, FetchNpmPackageFunctionDeclaration, GetLatestVersionFunctionDeclaration, GetPackageManagerFunctionDeclaration, GetUpgradeCommandFunctionDeclaration, LocateLockfileFunctionDeclaration, LocatePackageJsonFunctionDeclaration, UpgradeBuiltin, UpgradeFunctionDeclaration };
|
|
712
985
|
//# sourceMappingURL=upgrade-builtin.mjs.map
|