@granite-js/forge-cli 0.1.31 → 0.1.32
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/CHANGELOG.md +9 -0
- package/dist/index.js +19 -22
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,9 +2,6 @@ import { Command } from "@commander-js/extra-typings";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
|
|
4
4
|
import { loadSharedConfigFiles } from "@aws-sdk/shared-ini-file-loader";
|
|
5
|
-
import * as p$3 from "@clack/prompts";
|
|
6
|
-
import * as p$2 from "@clack/prompts";
|
|
7
|
-
import * as p$1 from "@clack/prompts";
|
|
8
5
|
import * as p from "@clack/prompts";
|
|
9
6
|
import { DeployManager, NoSuchKey, S3Client } from "@granite-js/deployment-manager";
|
|
10
7
|
import { loadConfig } from "@granite-js/plugin-core";
|
|
@@ -36,7 +33,7 @@ async function gzipFile({ inputFile, outputFile }) {
|
|
|
36
33
|
//#region src/utils/handlePrompts.ts
|
|
37
34
|
function handlePrompts(title, task) {
|
|
38
35
|
return (...args) => {
|
|
39
|
-
p
|
|
36
|
+
p.intro(title);
|
|
40
37
|
try {
|
|
41
38
|
const result = task.call(null, ...args);
|
|
42
39
|
if (result instanceof Promise) result.catch(promptErrorHandler);
|
|
@@ -46,7 +43,7 @@ function handlePrompts(title, task) {
|
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
45
|
function promptErrorHandler(error) {
|
|
49
|
-
p
|
|
46
|
+
p.log.error(error instanceof Error ? error.message : String(error));
|
|
50
47
|
process.exit(1);
|
|
51
48
|
}
|
|
52
49
|
|
|
@@ -65,21 +62,21 @@ async function deployImpl({ androidBundle, iosBundle, appName, tag }, context) {
|
|
|
65
62
|
outputFile: gzippedIosBundle
|
|
66
63
|
})]);
|
|
67
64
|
const deploymentId = generateDeploymentId();
|
|
68
|
-
const deployedAt = new Date();
|
|
69
|
-
let spinner = p
|
|
65
|
+
const deployedAt = /* @__PURE__ */ new Date();
|
|
66
|
+
let spinner = p.spinner();
|
|
70
67
|
spinner.start("Fetching current deployment state...");
|
|
71
68
|
const currentDeploymentState = await DeployManager.readDeploymentState(appName, { s3Client }).catch(handleReadDeploymentStateError);
|
|
72
69
|
spinner.stop("Successfully fetched current deployment state");
|
|
73
70
|
let newDeploymentState;
|
|
74
71
|
if (currentDeploymentState != null) {
|
|
75
|
-
p
|
|
72
|
+
p.log.info("Planning rollout...");
|
|
76
73
|
newDeploymentState = await DeployManager.planRollout(currentDeploymentState, {
|
|
77
74
|
progress: 100,
|
|
78
75
|
targetDeploymentId: deploymentId
|
|
79
76
|
});
|
|
80
77
|
switch (newDeploymentState.type) {
|
|
81
78
|
case "STABLE":
|
|
82
|
-
p
|
|
79
|
+
p.log.info(`Stable deployment planned (target: ${newDeploymentState.deploymentId})`);
|
|
83
80
|
break;
|
|
84
81
|
case "CANARY":
|
|
85
82
|
case "PENDING":
|
|
@@ -87,20 +84,20 @@ async function deployImpl({ androidBundle, iosBundle, appName, tag }, context) {
|
|
|
87
84
|
process.exit(1);
|
|
88
85
|
}
|
|
89
86
|
} else {
|
|
90
|
-
p
|
|
87
|
+
p.log.warn("No deployment state found");
|
|
91
88
|
newDeploymentState = {
|
|
92
89
|
type: "STABLE",
|
|
93
90
|
deploymentId
|
|
94
91
|
};
|
|
95
92
|
}
|
|
96
93
|
if (process.stdin.isTTY) {
|
|
97
|
-
const confirmed = await p
|
|
98
|
-
if (!confirmed || p
|
|
99
|
-
p
|
|
94
|
+
const confirmed = await p.confirm({ message: `Are you sure you want to deploy ${appName}?` });
|
|
95
|
+
if (!confirmed || p.isCancel(confirmed)) {
|
|
96
|
+
p.outro("Deployment cancelled");
|
|
100
97
|
process.exit(0);
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
|
-
await p
|
|
100
|
+
await p.tasks([{
|
|
104
101
|
bundlePath: gzippedAndroidBundle,
|
|
105
102
|
platform: "android"
|
|
106
103
|
}, {
|
|
@@ -120,7 +117,7 @@ async function deployImpl({ androidBundle, iosBundle, appName, tag }, context) {
|
|
|
120
117
|
return "Bundle uploaded";
|
|
121
118
|
}
|
|
122
119
|
})));
|
|
123
|
-
spinner = p
|
|
120
|
+
spinner = p.spinner();
|
|
124
121
|
spinner.start("Updating bundle list...");
|
|
125
122
|
await DeployManager.updateBundleList({
|
|
126
123
|
appName,
|
|
@@ -130,14 +127,14 @@ async function deployImpl({ androidBundle, iosBundle, appName, tag }, context) {
|
|
|
130
127
|
}
|
|
131
128
|
}, { s3Client });
|
|
132
129
|
spinner.stop("Bundle list updated");
|
|
133
|
-
spinner = p
|
|
130
|
+
spinner = p.spinner();
|
|
134
131
|
spinner.start(`Deploying ${appName}@${deploymentId}...`);
|
|
135
132
|
await DeployManager.rollout({
|
|
136
133
|
state: newDeploymentState,
|
|
137
134
|
appName
|
|
138
135
|
}, { s3Client });
|
|
139
136
|
spinner.stop(`Deployed successfully! (Deployment ID: ${deploymentId})`);
|
|
140
|
-
p
|
|
137
|
+
p.outro("Done");
|
|
141
138
|
}
|
|
142
139
|
function handleReadDeploymentStateError(error) {
|
|
143
140
|
if (error instanceof NoSuchKey) return null;
|
|
@@ -171,8 +168,8 @@ function deploy() {
|
|
|
171
168
|
const path$1 = issue.path?.[0];
|
|
172
169
|
return path$1 ? `process.env.${path$1.key}` : "unknown variable";
|
|
173
170
|
});
|
|
174
|
-
p
|
|
175
|
-
for (const missingVar of missingVars) p
|
|
171
|
+
p.log.error(`Required environment variables are not set:`);
|
|
172
|
+
for (const missingVar of missingVars) p.log.error(`${missingVar}`);
|
|
176
173
|
process.exit(1);
|
|
177
174
|
}
|
|
178
175
|
await deploy$1({
|
|
@@ -199,8 +196,7 @@ async function getRegion() {
|
|
|
199
196
|
const region = configFile?.[currentProfile]?.region;
|
|
200
197
|
if (region != null) return region;
|
|
201
198
|
}
|
|
202
|
-
|
|
203
|
-
return defaultRegion;
|
|
199
|
+
return configFile.default?.region;
|
|
204
200
|
}
|
|
205
201
|
|
|
206
202
|
//#endregion
|
|
@@ -252,4 +248,5 @@ program.addCommand(deploy());
|
|
|
252
248
|
program.addCommand(deployList());
|
|
253
249
|
program.parse();
|
|
254
250
|
|
|
255
|
-
//#endregion
|
|
251
|
+
//#endregion
|
|
252
|
+
export { };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@granite-js/forge-cli",
|
|
3
3
|
"description": "A CLI tool for managing Granite applications",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.32",
|
|
6
6
|
"bin": {
|
|
7
7
|
"granite-forge": "./bin/index.js"
|
|
8
8
|
},
|
|
@@ -24,18 +24,18 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^22.10.2",
|
|
27
|
-
"@vitest/coverage-v8": "^
|
|
28
|
-
"tsdown": "^0.
|
|
27
|
+
"@vitest/coverage-v8": "^4.0.12",
|
|
28
|
+
"tsdown": "^0.16.5",
|
|
29
29
|
"typescript": "^5.8.3",
|
|
30
|
-
"vitest": "^
|
|
30
|
+
"vitest": "^4.0.12"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@aws-sdk/credential-providers": "^3.817.0",
|
|
34
34
|
"@aws-sdk/shared-ini-file-loader": "^3.374.0",
|
|
35
35
|
"@clack/prompts": "^0.10.1",
|
|
36
36
|
"@commander-js/extra-typings": "^14.0.0",
|
|
37
|
-
"@granite-js/deployment-manager": "0.1.
|
|
38
|
-
"@granite-js/plugin-core": "0.1.
|
|
37
|
+
"@granite-js/deployment-manager": "0.1.32",
|
|
38
|
+
"@granite-js/plugin-core": "0.1.32",
|
|
39
39
|
"commander": "^14.0.0",
|
|
40
40
|
"uuid": "^11.1.0",
|
|
41
41
|
"valibot": "^1.1.0"
|