gistajs 0.1.13 → 0.2.0
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/bin.cjs +39 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -3
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -166,6 +166,17 @@ async function runInput(command, args, cwd, input) {
|
|
|
166
166
|
input
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
+
async function assertCommand(runFn, cwd, command, args, failureMessage) {
|
|
170
|
+
try {
|
|
171
|
+
await runFn(command, args, cwd);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
let code = error.code;
|
|
174
|
+
if (code === "ENOENT") {
|
|
175
|
+
throw new Error(`Required command not found: ${command}`);
|
|
176
|
+
}
|
|
177
|
+
throw new Error(failureMessage);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
169
180
|
async function exec(command, args, cwd, options) {
|
|
170
181
|
return await new Promise((resolve2, reject) => {
|
|
171
182
|
let { capture, input } = options;
|
|
@@ -334,7 +345,7 @@ async function runCreateCommand(argv, deps) {
|
|
|
334
345
|
let root = await deps.createProject(starter, options);
|
|
335
346
|
deps.stdout.log(
|
|
336
347
|
`
|
|
337
|
-
${c.brand("gistajs")}
|
|
348
|
+
${c.brand("gistajs")} created ${c.slug(starter.slug)} project in ${c.path(root)}
|
|
338
349
|
`
|
|
339
350
|
);
|
|
340
351
|
}
|
|
@@ -1131,6 +1142,7 @@ async function runProjectProvision(deps) {
|
|
|
1131
1142
|
}
|
|
1132
1143
|
let cliVersion = await deps.getCliVersion();
|
|
1133
1144
|
assertCliVersion(cliVersion, requirement);
|
|
1145
|
+
await assertProviderCommands(providers, deps);
|
|
1134
1146
|
let region = await resolveProjectRegion(pkg, deps);
|
|
1135
1147
|
await writeProjectRegion(pkg, region.id, deps);
|
|
1136
1148
|
let summary = {
|
|
@@ -1161,6 +1173,14 @@ async function runProjectProvision(deps) {
|
|
|
1161
1173
|
}
|
|
1162
1174
|
printSummary(summary, deps);
|
|
1163
1175
|
}
|
|
1176
|
+
async function assertProviderCommands(providers, deps) {
|
|
1177
|
+
let commands = providers.filter(
|
|
1178
|
+
(provider) => provider === "turso" || provider === "vercel"
|
|
1179
|
+
);
|
|
1180
|
+
for (let command of new Set(commands)) {
|
|
1181
|
+
await deps.assertCommandAvailable(deps.cwd, command);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1164
1184
|
async function readProvisionPackage(deps) {
|
|
1165
1185
|
return await readProjectPackage(deps.cwd, deps.readFile);
|
|
1166
1186
|
}
|
|
@@ -1580,11 +1600,26 @@ async function readCliVersion() {
|
|
|
1580
1600
|
if (false) {
|
|
1581
1601
|
throw new Error("Could not resolve the installed gistajs version");
|
|
1582
1602
|
}
|
|
1583
|
-
return "0.
|
|
1603
|
+
return "0.2.0";
|
|
1584
1604
|
}
|
|
1585
1605
|
async function runProjectCommand(cwd, script) {
|
|
1586
1606
|
await run("pnpm", [script], cwd);
|
|
1587
1607
|
}
|
|
1608
|
+
async function assertCommandAvailable(cwd, command) {
|
|
1609
|
+
let installHint = installHints[command];
|
|
1610
|
+
await assertCommand(
|
|
1611
|
+
run,
|
|
1612
|
+
cwd,
|
|
1613
|
+
command,
|
|
1614
|
+
["--help"],
|
|
1615
|
+
installHint ? `Required command not found: ${command}. ${installHint}` : `Required command not found: ${command}`
|
|
1616
|
+
);
|
|
1617
|
+
}
|
|
1618
|
+
var installHints = {
|
|
1619
|
+
atlas: "Install: https://atlasgo.io/guides/evaluation/install. If you have mise installed: `mise use -g atlas`",
|
|
1620
|
+
turso: "Install: https://docs.turso.tech/cli/installation. If you have mise installed: `mise use -g turso`",
|
|
1621
|
+
vercel: "Install: https://vercel.com/docs/cli. If you have mise installed: `mise use -g npm:vercel`"
|
|
1622
|
+
};
|
|
1588
1623
|
async function readDefaultProvisionRegion() {
|
|
1589
1624
|
try {
|
|
1590
1625
|
let response = await fetch("https://region.turso.io");
|
|
@@ -1620,7 +1655,8 @@ var defaultDeps4 = {
|
|
|
1620
1655
|
cwd: import_node_process5.default.cwd(),
|
|
1621
1656
|
getCliVersion: readCliVersion,
|
|
1622
1657
|
getDefaultProvisionRegion: readDefaultProvisionRegion,
|
|
1623
|
-
runProjectCommand
|
|
1658
|
+
runProjectCommand,
|
|
1659
|
+
assertCommandAvailable
|
|
1624
1660
|
};
|
|
1625
1661
|
|
|
1626
1662
|
// src/cli.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -142,6 +142,7 @@ type CliDeps = {
|
|
|
142
142
|
getCliVersion: () => Promise<string>;
|
|
143
143
|
getDefaultProvisionRegion: () => Promise<string | null>;
|
|
144
144
|
runProjectCommand: (cwd: string, script: string) => Promise<void>;
|
|
145
|
+
assertCommandAvailable: (cwd: string, command: string) => Promise<void>;
|
|
145
146
|
};
|
|
146
147
|
|
|
147
148
|
declare function runCli(argv?: string[], deps?: CliDeps): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -151,6 +151,17 @@ async function runInput(command, args, cwd, input) {
|
|
|
151
151
|
input
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
+
async function assertCommand(runFn, cwd, command, args, failureMessage) {
|
|
155
|
+
try {
|
|
156
|
+
await runFn(command, args, cwd);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
let code = error.code;
|
|
159
|
+
if (code === "ENOENT") {
|
|
160
|
+
throw new Error(`Required command not found: ${command}`);
|
|
161
|
+
}
|
|
162
|
+
throw new Error(failureMessage);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
154
165
|
async function exec(command, args, cwd, options) {
|
|
155
166
|
return await new Promise((resolve2, reject) => {
|
|
156
167
|
let { capture, input } = options;
|
|
@@ -319,7 +330,7 @@ async function runCreateCommand(argv, deps) {
|
|
|
319
330
|
let root = await deps.createProject(starter, options);
|
|
320
331
|
deps.stdout.log(
|
|
321
332
|
`
|
|
322
|
-
${c.brand("gistajs")}
|
|
333
|
+
${c.brand("gistajs")} created ${c.slug(starter.slug)} project in ${c.path(root)}
|
|
323
334
|
`
|
|
324
335
|
);
|
|
325
336
|
}
|
|
@@ -1116,6 +1127,7 @@ async function runProjectProvision(deps) {
|
|
|
1116
1127
|
}
|
|
1117
1128
|
let cliVersion = await deps.getCliVersion();
|
|
1118
1129
|
assertCliVersion(cliVersion, requirement);
|
|
1130
|
+
await assertProviderCommands(providers, deps);
|
|
1119
1131
|
let region = await resolveProjectRegion(pkg, deps);
|
|
1120
1132
|
await writeProjectRegion(pkg, region.id, deps);
|
|
1121
1133
|
let summary = {
|
|
@@ -1146,6 +1158,14 @@ async function runProjectProvision(deps) {
|
|
|
1146
1158
|
}
|
|
1147
1159
|
printSummary(summary, deps);
|
|
1148
1160
|
}
|
|
1161
|
+
async function assertProviderCommands(providers, deps) {
|
|
1162
|
+
let commands = providers.filter(
|
|
1163
|
+
(provider) => provider === "turso" || provider === "vercel"
|
|
1164
|
+
);
|
|
1165
|
+
for (let command of new Set(commands)) {
|
|
1166
|
+
await deps.assertCommandAvailable(deps.cwd, command);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1149
1169
|
async function readProvisionPackage(deps) {
|
|
1150
1170
|
return await readProjectPackage(deps.cwd, deps.readFile);
|
|
1151
1171
|
}
|
|
@@ -1565,11 +1585,26 @@ async function readCliVersion() {
|
|
|
1565
1585
|
if (false) {
|
|
1566
1586
|
throw new Error("Could not resolve the installed gistajs version");
|
|
1567
1587
|
}
|
|
1568
|
-
return "0.
|
|
1588
|
+
return "0.2.0";
|
|
1569
1589
|
}
|
|
1570
1590
|
async function runProjectCommand(cwd, script) {
|
|
1571
1591
|
await run("pnpm", [script], cwd);
|
|
1572
1592
|
}
|
|
1593
|
+
async function assertCommandAvailable(cwd, command) {
|
|
1594
|
+
let installHint = installHints[command];
|
|
1595
|
+
await assertCommand(
|
|
1596
|
+
run,
|
|
1597
|
+
cwd,
|
|
1598
|
+
command,
|
|
1599
|
+
["--help"],
|
|
1600
|
+
installHint ? `Required command not found: ${command}. ${installHint}` : `Required command not found: ${command}`
|
|
1601
|
+
);
|
|
1602
|
+
}
|
|
1603
|
+
var installHints = {
|
|
1604
|
+
atlas: "Install: https://atlasgo.io/guides/evaluation/install. If you have mise installed: `mise use -g atlas`",
|
|
1605
|
+
turso: "Install: https://docs.turso.tech/cli/installation. If you have mise installed: `mise use -g turso`",
|
|
1606
|
+
vercel: "Install: https://vercel.com/docs/cli. If you have mise installed: `mise use -g npm:vercel`"
|
|
1607
|
+
};
|
|
1573
1608
|
async function readDefaultProvisionRegion() {
|
|
1574
1609
|
try {
|
|
1575
1610
|
let response = await fetch("https://region.turso.io");
|
|
@@ -1605,7 +1640,8 @@ var defaultDeps4 = {
|
|
|
1605
1640
|
cwd: process5.cwd(),
|
|
1606
1641
|
getCliVersion: readCliVersion,
|
|
1607
1642
|
getDefaultProvisionRegion: readDefaultProvisionRegion,
|
|
1608
|
-
runProjectCommand
|
|
1643
|
+
runProjectCommand,
|
|
1644
|
+
assertCommandAvailable
|
|
1609
1645
|
};
|
|
1610
1646
|
|
|
1611
1647
|
// src/cli.ts
|