create-cloudflare 0.0.0-c5f3bf45 → 0.0.0-cc9ced83
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 -22
- package/package.json +1 -1
- package/templates/chatgptPlugin/ts/wrangler.toml +2 -2
- package/templates/common/js/wrangler.toml +1 -1
- package/templates/common/ts/wrangler.toml +1 -1
- package/templates/hello-world/js/wrangler.toml +1 -1
- package/templates/hello-world/ts/wrangler.toml +1 -1
- package/templates/queues/js/wrangler.toml +1 -1
- package/templates/queues/ts/wrangler.toml +1 -1
- package/templates/scheduled/js/wrangler.toml +1 -1
package/dist/cli.js
CHANGED
|
@@ -59419,7 +59419,7 @@ var Yargs = YargsFactory(esm_default);
|
|
|
59419
59419
|
var yargs_default = Yargs;
|
|
59420
59420
|
|
|
59421
59421
|
// package.json
|
|
59422
|
-
var version = "0.0.0-
|
|
59422
|
+
var version = "0.0.0-cc9ced83";
|
|
59423
59423
|
|
|
59424
59424
|
// src/common.ts
|
|
59425
59425
|
var import_fs6 = require("fs");
|
|
@@ -59474,26 +59474,26 @@ var detectPackageManager = () => {
|
|
|
59474
59474
|
};
|
|
59475
59475
|
|
|
59476
59476
|
// src/helpers/command.ts
|
|
59477
|
-
var runCommand = async (command2, opts) => {
|
|
59477
|
+
var runCommand = async (command2, opts = {}) => {
|
|
59478
59478
|
if (typeof command2 === "string") {
|
|
59479
59479
|
command2 = command2.trim().replace(/\s+/g, ` `).split(" ");
|
|
59480
59480
|
}
|
|
59481
59481
|
return printAsyncStatus({
|
|
59482
|
-
useSpinner: opts
|
|
59483
|
-
startText: opts
|
|
59484
|
-
doneText: opts
|
|
59482
|
+
useSpinner: opts.useSpinner ?? opts.silent,
|
|
59483
|
+
startText: opts.startText || command2.join(" "),
|
|
59484
|
+
doneText: opts.doneText,
|
|
59485
59485
|
promise() {
|
|
59486
59486
|
const [executable, ...args] = command2;
|
|
59487
|
-
const squelch = opts
|
|
59487
|
+
const squelch = opts.silent || process.env.VITEST;
|
|
59488
59488
|
const cmd = (0, import_cross_spawn.spawn)(executable, [...args], {
|
|
59489
59489
|
// TODO: ideally inherit stderr, but npm install uses this for warnings
|
|
59490
59490
|
// stdio: [ioMode, ioMode, "inherit"],
|
|
59491
59491
|
stdio: squelch ? "pipe" : "inherit",
|
|
59492
59492
|
env: {
|
|
59493
59493
|
...process.env,
|
|
59494
|
-
...opts
|
|
59494
|
+
...opts.env
|
|
59495
59495
|
},
|
|
59496
|
-
cwd: opts
|
|
59496
|
+
cwd: opts.cwd
|
|
59497
59497
|
});
|
|
59498
59498
|
let output = ``;
|
|
59499
59499
|
if (opts?.captureOutput ?? squelch) {
|
|
@@ -59506,10 +59506,19 @@ var runCommand = async (command2, opts) => {
|
|
|
59506
59506
|
}
|
|
59507
59507
|
return new Promise((resolve9, reject) => {
|
|
59508
59508
|
cmd.on("close", (code) => {
|
|
59509
|
-
|
|
59510
|
-
|
|
59511
|
-
|
|
59512
|
-
|
|
59509
|
+
try {
|
|
59510
|
+
if (code !== 0) {
|
|
59511
|
+
throw new Error(output, { cause: code });
|
|
59512
|
+
}
|
|
59513
|
+
const transformOutput = opts.transformOutput ?? ((result) => result);
|
|
59514
|
+
const processedOutput = transformOutput(stripAnsi(output));
|
|
59515
|
+
resolve9(processedOutput);
|
|
59516
|
+
} catch (e) {
|
|
59517
|
+
if (opts.fallbackOutput) {
|
|
59518
|
+
resolve9(opts.fallbackOutput(e));
|
|
59519
|
+
} else {
|
|
59520
|
+
reject(new Error(output, { cause: e }));
|
|
59521
|
+
}
|
|
59513
59522
|
}
|
|
59514
59523
|
});
|
|
59515
59524
|
});
|
|
@@ -59522,9 +59531,11 @@ async function runCommands({ commands, ...opts }) {
|
|
|
59522
59531
|
startText: opts.startText,
|
|
59523
59532
|
doneText: opts.doneText,
|
|
59524
59533
|
async promise() {
|
|
59534
|
+
const results = [];
|
|
59525
59535
|
for (const command2 of commands) {
|
|
59526
|
-
await runCommand(command2, { ...opts, useSpinner: false });
|
|
59536
|
+
results.push(await runCommand(command2, { ...opts, useSpinner: false }));
|
|
59527
59537
|
}
|
|
59538
|
+
return results.join("\n");
|
|
59528
59539
|
}
|
|
59529
59540
|
});
|
|
59530
59541
|
}
|
|
@@ -59541,8 +59552,9 @@ var printAsyncStatus = async ({
|
|
|
59541
59552
|
promise = promise();
|
|
59542
59553
|
}
|
|
59543
59554
|
try {
|
|
59544
|
-
await promise;
|
|
59545
|
-
|
|
59555
|
+
const output = await promise;
|
|
59556
|
+
const doneText = typeof opts.doneText === "function" ? opts.doneText(output) : opts.doneText;
|
|
59557
|
+
s?.stop(doneText);
|
|
59546
59558
|
} catch (err) {
|
|
59547
59559
|
s?.stop(err.message);
|
|
59548
59560
|
} finally {
|
|
@@ -59655,6 +59667,24 @@ var listAccounts = async () => {
|
|
|
59655
59667
|
});
|
|
59656
59668
|
return accounts;
|
|
59657
59669
|
};
|
|
59670
|
+
async function getWorkerdCompatibilityDate() {
|
|
59671
|
+
const { npm: npm12 } = detectPackageManager();
|
|
59672
|
+
return runCommand(`${npm12} info workerd dist-tags.latest`, {
|
|
59673
|
+
silent: true,
|
|
59674
|
+
captureOutput: true,
|
|
59675
|
+
startText: "Retrieving current workerd compatibility date",
|
|
59676
|
+
transformOutput: (result) => {
|
|
59677
|
+
const match = result.match(/\d+\.(\d{4})(\d{2})(\d{2})\.\d+/);
|
|
59678
|
+
if (!match) {
|
|
59679
|
+
throw new Error("Could not find workerd date");
|
|
59680
|
+
}
|
|
59681
|
+
const [, year, month, date] = match;
|
|
59682
|
+
return `${year}-${month}-${date}`;
|
|
59683
|
+
},
|
|
59684
|
+
fallbackOutput: () => "2023-05-18",
|
|
59685
|
+
doneText: (output) => `${brandColor("compatibility date")} ${dim(output)}`
|
|
59686
|
+
});
|
|
59687
|
+
}
|
|
59658
59688
|
|
|
59659
59689
|
// src/helpers/poll.ts
|
|
59660
59690
|
var import_promises = require("node:dns/promises");
|
|
@@ -60849,10 +60879,12 @@ async function updateFiles(ctx) {
|
|
|
60849
60879
|
packagejson: JSON.parse(await (0, import_promises3.readFile)(paths.packagejson, "utf-8")),
|
|
60850
60880
|
wranglertoml: await (0, import_promises3.readFile)(paths.wranglertoml, "utf-8")
|
|
60851
60881
|
};
|
|
60852
|
-
contents.packagejson.name
|
|
60853
|
-
|
|
60854
|
-
|
|
60855
|
-
|
|
60882
|
+
if (contents.packagejson.name === "<TBD>") {
|
|
60883
|
+
contents.packagejson.name = ctx.project.name;
|
|
60884
|
+
}
|
|
60885
|
+
contents.wranglertoml = contents.wranglertoml.replace(/^name\s*=\s*"<TBD>"/m, `name = "${ctx.project.name}"`).replace(
|
|
60886
|
+
/^compatibility_date\s*=\s*"<TBD>"/m,
|
|
60887
|
+
`compatibility_date = "${await getWorkerdCompatibilityDate()}"`
|
|
60856
60888
|
);
|
|
60857
60889
|
await (0, import_promises3.writeFile)(
|
|
60858
60890
|
paths.packagejson,
|
|
@@ -60863,8 +60895,8 @@ async function updateFiles(ctx) {
|
|
|
60863
60895
|
|
|
60864
60896
|
// src/cli.ts
|
|
60865
60897
|
var main = async (argv) => {
|
|
60866
|
-
printBanner();
|
|
60867
60898
|
const args = await parseArgs(argv);
|
|
60899
|
+
printBanner();
|
|
60868
60900
|
const validatedArgs = {
|
|
60869
60901
|
...args,
|
|
60870
60902
|
projectName: await validateName(args.projectName, {
|
|
@@ -60891,7 +60923,7 @@ var parseArgs = async (argv) => {
|
|
|
60891
60923
|
}).option("existing-script", {
|
|
60892
60924
|
type: "string",
|
|
60893
60925
|
hidden: templateMap["pre-existing"].hidden
|
|
60894
|
-
}).option("wrangler-defaults", { type: "boolean", hidden: true }).help().argv;
|
|
60926
|
+
}).option("wrangler-defaults", { type: "boolean", hidden: true }).version(version).help().argv;
|
|
60895
60927
|
return {
|
|
60896
60928
|
projectName: args._[0],
|
|
60897
60929
|
...args
|
|
@@ -60900,7 +60932,7 @@ var parseArgs = async (argv) => {
|
|
|
60900
60932
|
var validateName = async (name, { acceptDefault = false } = {}) => {
|
|
60901
60933
|
const defaultValue = name ?? new import_haikunator.default().haikunate({ tokenHex: true });
|
|
60902
60934
|
return textInput({
|
|
60903
|
-
question: `
|
|
60935
|
+
question: `In which directory do you want to create your application?`,
|
|
60904
60936
|
helpText: "also used as application name",
|
|
60905
60937
|
renderSubmitted: (value) => {
|
|
60906
60938
|
return `${brandColor("dir")} ${dim(value)}`;
|
package/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
name = "
|
|
1
|
+
name = "<TBD>"
|
|
2
2
|
main = "src/index.ts"
|
|
3
|
-
compatibility_date = "
|
|
3
|
+
compatibility_date = "<TBD>"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
name = "<TBD>"
|
|
2
2
|
main = "src/worker.js"
|
|
3
|
-
compatibility_date = "
|
|
3
|
+
compatibility_date = "<TBD>"
|
|
4
4
|
|
|
5
5
|
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
|
6
6
|
# Docs: https://developers.cloudflare.com/queues/get-started
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
name = "<TBD>"
|
|
2
2
|
main = "src/worker.ts"
|
|
3
|
-
compatibility_date = "
|
|
3
|
+
compatibility_date = "<TBD>"
|
|
4
4
|
|
|
5
5
|
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
|
6
6
|
# Docs: https://developers.cloudflare.com/queues/get-started
|