datasette-ts 0.0.14 → 0.0.15
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/cli.js +54 -20
- package/dist/cli.js.map +4 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -23685,6 +23685,9 @@ var init_node4 = __esm({
|
|
|
23685
23685
|
}
|
|
23686
23686
|
});
|
|
23687
23687
|
|
|
23688
|
+
// src/cli.ts
|
|
23689
|
+
import { parseArgs as parseArgs2 } from "node:util";
|
|
23690
|
+
|
|
23688
23691
|
// src/cli/deploy-cloudflare.ts
|
|
23689
23692
|
import { mkdir as mkdir2, stat as stat2, writeFile } from "node:fs/promises";
|
|
23690
23693
|
import { dirname, extname, join, relative, resolve } from "node:path";
|
|
@@ -24695,29 +24698,39 @@ function parseNamedArg2(arg, nextValue) {
|
|
|
24695
24698
|
}
|
|
24696
24699
|
|
|
24697
24700
|
// src/cli.ts
|
|
24698
|
-
var keepAlive = setInterval(() => {
|
|
24699
|
-
}, 1e3);
|
|
24700
24701
|
var mainPromise = main();
|
|
24701
24702
|
mainPromise.catch((error) => {
|
|
24702
24703
|
console.error(error);
|
|
24703
24704
|
process.exitCode = 1;
|
|
24704
24705
|
});
|
|
24705
|
-
mainPromise.finally(() => {
|
|
24706
|
-
clearInterval(keepAlive);
|
|
24707
|
-
});
|
|
24708
24706
|
async function main() {
|
|
24709
24707
|
const args = process.argv.slice(2);
|
|
24710
|
-
const
|
|
24711
|
-
|
|
24712
|
-
|
|
24713
|
-
|
|
24714
|
-
|
|
24715
|
-
|
|
24716
|
-
|
|
24717
|
-
|
|
24708
|
+
const parsed = parseArgs2({
|
|
24709
|
+
args,
|
|
24710
|
+
allowPositionals: true,
|
|
24711
|
+
strict: false,
|
|
24712
|
+
options: {
|
|
24713
|
+
help: { type: "boolean", short: "h" }
|
|
24714
|
+
},
|
|
24715
|
+
tokens: true
|
|
24716
|
+
});
|
|
24717
|
+
const [command, subcommand] = parsed.positionals;
|
|
24718
|
+
const positionalIndices = (parsed.tokens ?? []).filter((token) => token.kind === "positional").map((token) => token.index).sort((a, b) => a - b);
|
|
24719
|
+
if (!command) {
|
|
24720
|
+
if (parsed.values.help) {
|
|
24721
|
+
printHelp();
|
|
24722
|
+
return;
|
|
24718
24723
|
}
|
|
24719
|
-
|
|
24720
|
-
|
|
24724
|
+
if (hasHelpFlag(args)) {
|
|
24725
|
+
printServeHelp();
|
|
24726
|
+
return;
|
|
24727
|
+
}
|
|
24728
|
+
await runServeCommand(args);
|
|
24729
|
+
return;
|
|
24730
|
+
}
|
|
24731
|
+
if (command === "serve") {
|
|
24732
|
+
const serveArgs = dropPositionals(args, positionalIndices, 1);
|
|
24733
|
+
if (hasHelpFlag(serveArgs)) {
|
|
24721
24734
|
printServeHelp();
|
|
24722
24735
|
return;
|
|
24723
24736
|
}
|
|
@@ -24725,8 +24738,8 @@ async function main() {
|
|
|
24725
24738
|
return;
|
|
24726
24739
|
}
|
|
24727
24740
|
if (command === "inspect") {
|
|
24728
|
-
const inspectArgs = args
|
|
24729
|
-
if (
|
|
24741
|
+
const inspectArgs = dropPositionals(args, positionalIndices, 1);
|
|
24742
|
+
if (hasHelpFlag(inspectArgs)) {
|
|
24730
24743
|
printInspectHelp();
|
|
24731
24744
|
return;
|
|
24732
24745
|
}
|
|
@@ -24739,15 +24752,15 @@ async function main() {
|
|
|
24739
24752
|
process.exitCode = 1;
|
|
24740
24753
|
return;
|
|
24741
24754
|
}
|
|
24742
|
-
const deployArgs = args
|
|
24743
|
-
if (
|
|
24755
|
+
const deployArgs = dropPositionals(args, positionalIndices, 2);
|
|
24756
|
+
if (hasHelpFlag(deployArgs)) {
|
|
24744
24757
|
printDeployHelp();
|
|
24745
24758
|
return;
|
|
24746
24759
|
}
|
|
24747
24760
|
await runCloudflareDeploy(deployArgs);
|
|
24748
24761
|
return;
|
|
24749
24762
|
}
|
|
24750
|
-
if (command === "help"
|
|
24763
|
+
if (command === "help") {
|
|
24751
24764
|
printHelp();
|
|
24752
24765
|
return;
|
|
24753
24766
|
}
|
|
@@ -24755,6 +24768,27 @@ async function main() {
|
|
|
24755
24768
|
printHelp();
|
|
24756
24769
|
process.exitCode = 1;
|
|
24757
24770
|
}
|
|
24771
|
+
function dropPositionals(args, positionalIndices, count) {
|
|
24772
|
+
if (count <= 0) {
|
|
24773
|
+
return args.slice();
|
|
24774
|
+
}
|
|
24775
|
+
const remove = new Set(positionalIndices.slice(0, count));
|
|
24776
|
+
if (remove.size === 0) {
|
|
24777
|
+
return args.slice();
|
|
24778
|
+
}
|
|
24779
|
+
return args.filter((_, index) => !remove.has(index));
|
|
24780
|
+
}
|
|
24781
|
+
function hasHelpFlag(args) {
|
|
24782
|
+
const parsed = parseArgs2({
|
|
24783
|
+
args,
|
|
24784
|
+
allowPositionals: true,
|
|
24785
|
+
strict: false,
|
|
24786
|
+
options: {
|
|
24787
|
+
help: { type: "boolean", short: "h" }
|
|
24788
|
+
}
|
|
24789
|
+
});
|
|
24790
|
+
return parsed.values.help === true;
|
|
24791
|
+
}
|
|
24758
24792
|
function printHelp() {
|
|
24759
24793
|
console.log(`datasette-ts
|
|
24760
24794
|
|