create-cloudflare 0.0.0-e8df68ee → 0.0.0-ec358f4f
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/angular/templates/tools/bundle.mjs +5 -2
- package/dist/cli.js +351 -294
- package/package.json +2 -2
- package/templates/chatgptPlugin/ts/README.md +1 -1
- package/templates/chatgptPlugin/ts/package.json +1 -1
- package/templates/chatgptPlugin/ts/wrangler.toml +2 -2
- package/templates/common/js/package.json +1 -2
- package/templates/common/js/wrangler.toml +1 -1
- package/templates/common/ts/package.json +1 -1
- package/templates/common/ts/wrangler.toml +1 -1
- package/templates/hello-world/js/package.json +1 -3
- package/templates/hello-world/js/wrangler.toml +1 -1
- package/templates/hello-world/ts/package.json +1 -1
- package/templates/hello-world/ts/wrangler.toml +1 -1
- package/templates/queues/js/package.json +1 -3
- package/templates/queues/js/wrangler.toml +1 -1
- package/templates/queues/ts/package.json +1 -1
- package/templates/queues/ts/wrangler.toml +1 -1
- package/templates/scheduled/js/package.json +1 -3
- package/templates/scheduled/js/wrangler.toml +1 -1
- package/templates/scheduled/ts/package.json +1 -1
|
@@ -37,7 +37,8 @@ async function bundleMain() {
|
|
|
37
37
|
],
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
// Store the original promise (before Angular/Zone.js replaces it) on the global scope.
|
|
41
|
+
let main = "globalThis.OGPromise = Promise;\n" + result.outputFiles[0].text;
|
|
41
42
|
|
|
42
43
|
// Patch any dynamic imports (converting `require()` calls to `import()` calls).
|
|
43
44
|
main = main.replace(
|
|
@@ -45,7 +46,9 @@ async function bundleMain() {
|
|
|
45
46
|
'promises.push(import("./" + __webpack_require__.u(chunkId)).then((mod) => installChunk(mod.default))'
|
|
46
47
|
);
|
|
47
48
|
// Export the fetch handler (grabbing it from the global).
|
|
48
|
-
|
|
49
|
+
// Also Cloudflare expects `fetch()` to return an original Promise (not a ZoneAwarePromise).
|
|
50
|
+
main +=
|
|
51
|
+
"\nexport default { fetch: (request, env) => globalThis.OGPromise.resolve(globalThis.__workerFetchHandler(request, env)) };";
|
|
49
52
|
|
|
50
53
|
await fs.writeFile(path.resolve(workerPath, "index.js"), main);
|
|
51
54
|
}
|
package/dist/cli.js
CHANGED
|
@@ -52612,7 +52612,9 @@ var require_typescript2 = __commonJS({
|
|
|
52612
52612
|
// src/cli.ts
|
|
52613
52613
|
var cli_exports = {};
|
|
52614
52614
|
__export(cli_exports, {
|
|
52615
|
-
|
|
52615
|
+
C3_DEFAULTS: () => C3_DEFAULTS,
|
|
52616
|
+
main: () => main,
|
|
52617
|
+
parseArgs: () => parseArgs
|
|
52616
52618
|
});
|
|
52617
52619
|
module.exports = __toCommonJS(cli_exports);
|
|
52618
52620
|
var import_haikunator = __toESM(require_dist_node());
|
|
@@ -53150,11 +53152,9 @@ var status = {
|
|
|
53150
53152
|
success: bgRed(` SUCCESS `)
|
|
53151
53153
|
};
|
|
53152
53154
|
var space = (n = 1) => {
|
|
53153
|
-
return
|
|
53155
|
+
return hidden("\u200A".repeat(n));
|
|
53154
53156
|
};
|
|
53155
53157
|
var logRaw = (msg) => {
|
|
53156
|
-
if (process.env.VITEST)
|
|
53157
|
-
return;
|
|
53158
53158
|
process.stdout.write(`${msg}
|
|
53159
53159
|
`);
|
|
53160
53160
|
};
|
|
@@ -54347,171 +54347,165 @@ var logUpdateStderr = createLogUpdate(import_node_process6.default.stderr);
|
|
|
54347
54347
|
var grayBar = gray(shapes.bar);
|
|
54348
54348
|
var blCorner = gray(shapes.corners.bl);
|
|
54349
54349
|
var leftT = gray(shapes.leftT);
|
|
54350
|
-
var
|
|
54351
|
-
|
|
54352
|
-
const
|
|
54353
|
-
|
|
54354
|
-
|
|
54355
|
-
|
|
54356
|
-
|
|
54357
|
-
|
|
54358
|
-
|
|
54359
|
-
|
|
54360
|
-
body += `${blCorner} ${bold(question)} ${dim(helpText)}
|
|
54361
|
-
`;
|
|
54362
|
-
body += `${space(2)}${gray(defaultValue)}
|
|
54363
|
-
`;
|
|
54364
|
-
break;
|
|
54365
|
-
case "active":
|
|
54366
|
-
body += `${blCorner} ${bold(question)} ${dim(helpText)}
|
|
54367
|
-
`;
|
|
54368
|
-
body += `${space(2)}${this.value}
|
|
54369
|
-
`;
|
|
54370
|
-
break;
|
|
54371
|
-
case "submit":
|
|
54372
|
-
body += `${leftT} ${question}
|
|
54373
|
-
`;
|
|
54374
|
-
body += `${grayBar} ${renderSubmitted(this.value)}
|
|
54375
|
-
${grayBar}`;
|
|
54376
|
-
break;
|
|
54377
|
-
case "error":
|
|
54378
|
-
body += `${leftT} ${status.error} ${dim(this.error)}
|
|
54379
|
-
`;
|
|
54380
|
-
body += `${grayBar}
|
|
54381
|
-
`;
|
|
54382
|
-
body += `${blCorner} ${question} ${dim(helpText)}
|
|
54383
|
-
`;
|
|
54384
|
-
body += `${space(2)}${this.value}
|
|
54385
|
-
`;
|
|
54386
|
-
break;
|
|
54387
|
-
default:
|
|
54388
|
-
break;
|
|
54389
|
-
}
|
|
54390
|
-
return body;
|
|
54391
|
-
}
|
|
54392
|
-
});
|
|
54393
|
-
let value;
|
|
54394
|
-
if (acceptDefault) {
|
|
54395
|
-
logRaw(`${leftT} ${question}`);
|
|
54396
|
-
logRaw(`${grayBar} ${renderSubmitted(defaultValue)}
|
|
54397
|
-
${grayBar}`);
|
|
54398
|
-
value = defaultValue;
|
|
54399
|
-
validate?.(value);
|
|
54400
|
-
} else {
|
|
54401
|
-
value = await prompt.prompt();
|
|
54402
|
-
if (eD(value)) {
|
|
54403
|
-
cancel("Operation cancelled.");
|
|
54404
|
-
process.exit(0);
|
|
54405
|
-
}
|
|
54406
|
-
}
|
|
54350
|
+
var processArgument = async (args, name, promptConfig) => {
|
|
54351
|
+
let value = args[name];
|
|
54352
|
+
const renderSubmitted = getRenderers(promptConfig).submit;
|
|
54353
|
+
if (value !== void 0) {
|
|
54354
|
+
promptConfig.validate?.(value);
|
|
54355
|
+
const lines = renderSubmitted({ value });
|
|
54356
|
+
logRaw(lines.join("\n"));
|
|
54357
|
+
return value;
|
|
54358
|
+
}
|
|
54359
|
+
value = await inputPrompt(promptConfig);
|
|
54407
54360
|
return value;
|
|
54408
54361
|
};
|
|
54409
|
-
var
|
|
54410
|
-
const
|
|
54411
|
-
|
|
54412
|
-
const
|
|
54413
|
-
|
|
54414
|
-
|
|
54415
|
-
|
|
54416
|
-
|
|
54417
|
-
|
|
54418
|
-
|
|
54419
|
-
|
|
54420
|
-
|
|
54421
|
-
|
|
54422
|
-
|
|
54423
|
-
let body = ``;
|
|
54424
|
-
switch (this.state) {
|
|
54425
|
-
case "submit":
|
|
54426
|
-
body += `${leftT} ${question}
|
|
54427
|
-
`;
|
|
54428
|
-
body += `${grayBar} ${renderSubmitted(options[this.cursor])}`;
|
|
54429
|
-
body += `
|
|
54430
|
-
${grayBar}`;
|
|
54431
|
-
break;
|
|
54432
|
-
default:
|
|
54433
|
-
body += `${blCorner} ${bold(question)} ${dim(helpText)}
|
|
54434
|
-
`;
|
|
54435
|
-
body += `${options.map(renderOption).join(`
|
|
54436
|
-
`)}
|
|
54437
|
-
`;
|
|
54438
|
-
break;
|
|
54362
|
+
var inputPrompt = async (promptConfig) => {
|
|
54363
|
+
const renderers = getRenderers(promptConfig);
|
|
54364
|
+
let prompt;
|
|
54365
|
+
const dispatchRender = (props) => {
|
|
54366
|
+
const renderedLines = renderers[props.state](props);
|
|
54367
|
+
return renderedLines.join("\n");
|
|
54368
|
+
};
|
|
54369
|
+
if (promptConfig.type === "select") {
|
|
54370
|
+
prompt = new ED({
|
|
54371
|
+
...promptConfig,
|
|
54372
|
+
options: promptConfig.options,
|
|
54373
|
+
initialValue: String(promptConfig.defaultValue),
|
|
54374
|
+
render() {
|
|
54375
|
+
return dispatchRender(this);
|
|
54439
54376
|
}
|
|
54440
|
-
|
|
54441
|
-
|
|
54442
|
-
|
|
54443
|
-
|
|
54444
|
-
|
|
54445
|
-
|
|
54446
|
-
|
|
54447
|
-
|
|
54448
|
-
|
|
54449
|
-
|
|
54450
|
-
|
|
54451
|
-
);
|
|
54452
|
-
logRaw(`${grayBar}`);
|
|
54453
|
-
value = defaultValue;
|
|
54377
|
+
});
|
|
54378
|
+
} else if (promptConfig.type === "confirm") {
|
|
54379
|
+
prompt = new sD({
|
|
54380
|
+
...promptConfig,
|
|
54381
|
+
initialValue: Boolean(promptConfig.defaultValue),
|
|
54382
|
+
active: promptConfig.activeText || "",
|
|
54383
|
+
inactive: promptConfig.inactiveText || "",
|
|
54384
|
+
render() {
|
|
54385
|
+
return dispatchRender(this);
|
|
54386
|
+
}
|
|
54387
|
+
});
|
|
54454
54388
|
} else {
|
|
54455
|
-
|
|
54456
|
-
|
|
54457
|
-
|
|
54458
|
-
|
|
54459
|
-
|
|
54389
|
+
prompt = new oD({
|
|
54390
|
+
...promptConfig,
|
|
54391
|
+
defaultValue: String(promptConfig.defaultValue),
|
|
54392
|
+
render() {
|
|
54393
|
+
return dispatchRender(this);
|
|
54394
|
+
}
|
|
54395
|
+
});
|
|
54460
54396
|
}
|
|
54461
|
-
|
|
54397
|
+
const input = await prompt.prompt();
|
|
54398
|
+
if (eD(input)) {
|
|
54399
|
+
cancel("Operation cancelled.");
|
|
54400
|
+
process.exit(0);
|
|
54401
|
+
}
|
|
54402
|
+
return input;
|
|
54462
54403
|
};
|
|
54463
|
-
var
|
|
54404
|
+
var renderSubmit = (config14, value) => {
|
|
54405
|
+
const { question, label } = config14;
|
|
54406
|
+
const content = config14.type === "confirm" ? `${grayBar} ${brandColor(value)} ${dim(label)}` : `${grayBar} ${brandColor(label)} ${dim(value)}`;
|
|
54407
|
+
return [`${leftT} ${question}`, content, `${grayBar}`];
|
|
54408
|
+
};
|
|
54409
|
+
var handleCancel = () => {
|
|
54410
|
+
cancel("Operation cancelled.");
|
|
54411
|
+
process.exit(0);
|
|
54412
|
+
};
|
|
54413
|
+
var getRenderers = (config14) => {
|
|
54414
|
+
switch (config14.type) {
|
|
54415
|
+
case "select":
|
|
54416
|
+
return getSelectRenderers(config14);
|
|
54417
|
+
case "confirm":
|
|
54418
|
+
return getConfirmRenderers(config14);
|
|
54419
|
+
case "text":
|
|
54420
|
+
return getTextRenderers(config14);
|
|
54421
|
+
}
|
|
54422
|
+
};
|
|
54423
|
+
var getTextRenderers = (config14) => {
|
|
54464
54424
|
const {
|
|
54465
|
-
|
|
54466
|
-
inactiveText,
|
|
54425
|
+
defaultValue,
|
|
54467
54426
|
question,
|
|
54468
|
-
|
|
54469
|
-
|
|
54470
|
-
|
|
54471
|
-
|
|
54472
|
-
const
|
|
54427
|
+
helpText: _helpText,
|
|
54428
|
+
format: _format
|
|
54429
|
+
} = config14;
|
|
54430
|
+
const helpText = _helpText ?? "";
|
|
54431
|
+
const format3 = _format ?? ((val) => String(val));
|
|
54432
|
+
return {
|
|
54433
|
+
initial: () => [
|
|
54434
|
+
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
54435
|
+
`${space(2)}${gray(format3(defaultValue))}`,
|
|
54436
|
+
``
|
|
54437
|
+
// extra line for readability
|
|
54438
|
+
],
|
|
54439
|
+
active: ({ value }) => [
|
|
54440
|
+
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
54441
|
+
`${space(2)}${format3(value || dim(defaultValue))}`,
|
|
54442
|
+
``
|
|
54443
|
+
// extra line for readability
|
|
54444
|
+
],
|
|
54445
|
+
error: ({ value, error }) => [
|
|
54446
|
+
`${leftT} ${status.error} ${dim(error)}`,
|
|
54447
|
+
`${grayBar}`,
|
|
54448
|
+
`${blCorner} ${question} ${dim(helpText)}`,
|
|
54449
|
+
`${space(2)}${format3(value)}`,
|
|
54450
|
+
``
|
|
54451
|
+
// extra line for readability
|
|
54452
|
+
],
|
|
54453
|
+
submit: ({ value }) => renderSubmit(config14, format3(value)),
|
|
54454
|
+
cancel: handleCancel
|
|
54455
|
+
};
|
|
54456
|
+
};
|
|
54457
|
+
var getSelectRenderers = (config14) => {
|
|
54458
|
+
const { options, question, helpText: _helpText } = config14;
|
|
54459
|
+
const helpText = _helpText ?? "";
|
|
54460
|
+
const defaultRenderer = ({ cursor }) => {
|
|
54461
|
+
const renderOption = (opt, i) => {
|
|
54462
|
+
const { label: optionLabel } = opt;
|
|
54463
|
+
const active = i === cursor;
|
|
54464
|
+
const text = active ? blue.underline(optionLabel) : dim(optionLabel);
|
|
54465
|
+
const indicator = active ? blue(shapes.radioActive) : dim(shapes.radioInactive);
|
|
54466
|
+
return `${space(2)}${indicator} ${text}`;
|
|
54467
|
+
};
|
|
54468
|
+
return [
|
|
54469
|
+
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
54470
|
+
`${options.map(renderOption).join(`
|
|
54471
|
+
`)}`,
|
|
54472
|
+
``
|
|
54473
|
+
// extra line for readability
|
|
54474
|
+
];
|
|
54475
|
+
};
|
|
54476
|
+
return {
|
|
54477
|
+
initial: defaultRenderer,
|
|
54478
|
+
active: defaultRenderer,
|
|
54479
|
+
confirm: defaultRenderer,
|
|
54480
|
+
error: defaultRenderer,
|
|
54481
|
+
submit: ({ value }) => renderSubmit(
|
|
54482
|
+
config14,
|
|
54483
|
+
options.find((o2) => o2.value === value)?.label
|
|
54484
|
+
),
|
|
54485
|
+
cancel: handleCancel
|
|
54486
|
+
};
|
|
54487
|
+
};
|
|
54488
|
+
var getConfirmRenderers = (config14) => {
|
|
54489
|
+
const { activeText, inactiveText, question, helpText: _helpText } = config14;
|
|
54490
|
+
const helpText = _helpText ?? "";
|
|
54473
54491
|
const active = activeText || "Yes";
|
|
54474
54492
|
const inactive = inactiveText || "No";
|
|
54475
|
-
const
|
|
54476
|
-
|
|
54477
|
-
|
|
54478
|
-
|
|
54479
|
-
|
|
54480
|
-
|
|
54481
|
-
|
|
54482
|
-
|
|
54483
|
-
|
|
54484
|
-
|
|
54485
|
-
|
|
54486
|
-
|
|
54487
|
-
|
|
54488
|
-
|
|
54489
|
-
|
|
54490
|
-
|
|
54491
|
-
default:
|
|
54492
|
-
body += `${blCorner} ${bold(question)} ${dim(helpText)}
|
|
54493
|
-
`;
|
|
54494
|
-
body += `${space(2)}${yesColor(active)} / ${noColor(inactive)}
|
|
54495
|
-
`;
|
|
54496
|
-
break;
|
|
54497
|
-
}
|
|
54498
|
-
return body;
|
|
54499
|
-
}
|
|
54500
|
-
});
|
|
54501
|
-
let value;
|
|
54502
|
-
if (acceptDefault) {
|
|
54503
|
-
logRaw(`${leftT} ${question}`);
|
|
54504
|
-
logRaw(`${grayBar} ${renderSubmitted(defaultValue)}`);
|
|
54505
|
-
logRaw(`${grayBar}`);
|
|
54506
|
-
value = defaultValue;
|
|
54507
|
-
} else {
|
|
54508
|
-
value = Boolean(await prompt.prompt());
|
|
54509
|
-
if (eD(value)) {
|
|
54510
|
-
cancel("Operation cancelled.");
|
|
54511
|
-
process.exit(0);
|
|
54512
|
-
}
|
|
54513
|
-
}
|
|
54514
|
-
return value;
|
|
54493
|
+
const defaultRenderer = ({ value }) => {
|
|
54494
|
+
const yesColor = value ? blue : dim;
|
|
54495
|
+
const noColor = value ? dim : blue;
|
|
54496
|
+
return [
|
|
54497
|
+
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
54498
|
+
`${space(2)}${yesColor(active)} / ${noColor(inactive)}`
|
|
54499
|
+
];
|
|
54500
|
+
};
|
|
54501
|
+
return {
|
|
54502
|
+
initial: defaultRenderer,
|
|
54503
|
+
active: defaultRenderer,
|
|
54504
|
+
confirm: defaultRenderer,
|
|
54505
|
+
error: defaultRenderer,
|
|
54506
|
+
submit: ({ value }) => renderSubmit(config14, value ? "yes" : "no"),
|
|
54507
|
+
cancel: handleCancel
|
|
54508
|
+
};
|
|
54515
54509
|
};
|
|
54516
54510
|
var spinner = () => {
|
|
54517
54511
|
const spinnerFrames = ["\u2524", "\u2518", "\u2534", "\u2514", "\u251C", "\u250C", "\u252C", "\u2510"];
|
|
@@ -59416,7 +59410,7 @@ var Yargs = YargsFactory(esm_default);
|
|
|
59416
59410
|
var yargs_default = Yargs;
|
|
59417
59411
|
|
|
59418
59412
|
// package.json
|
|
59419
|
-
var version = "0.0.0-
|
|
59413
|
+
var version = "0.0.0-ec358f4f";
|
|
59420
59414
|
|
|
59421
59415
|
// src/common.ts
|
|
59422
59416
|
var import_fs6 = require("fs");
|
|
@@ -59471,29 +59465,28 @@ var detectPackageManager = () => {
|
|
|
59471
59465
|
};
|
|
59472
59466
|
|
|
59473
59467
|
// src/helpers/command.ts
|
|
59474
|
-
var runCommand = async (command2, opts) => {
|
|
59468
|
+
var runCommand = async (command2, opts = {}) => {
|
|
59475
59469
|
if (typeof command2 === "string") {
|
|
59476
59470
|
command2 = command2.trim().replace(/\s+/g, ` `).split(" ");
|
|
59477
59471
|
}
|
|
59478
59472
|
return printAsyncStatus({
|
|
59479
|
-
useSpinner: opts
|
|
59480
|
-
startText: opts
|
|
59481
|
-
doneText: opts
|
|
59473
|
+
useSpinner: opts.useSpinner ?? opts.silent,
|
|
59474
|
+
startText: opts.startText || command2.join(" ").trim(),
|
|
59475
|
+
doneText: opts.doneText,
|
|
59482
59476
|
promise() {
|
|
59483
59477
|
const [executable, ...args] = command2;
|
|
59484
|
-
const squelch = opts?.silent || process.env.VITEST;
|
|
59485
59478
|
const cmd = (0, import_cross_spawn.spawn)(executable, [...args], {
|
|
59486
59479
|
// TODO: ideally inherit stderr, but npm install uses this for warnings
|
|
59487
59480
|
// stdio: [ioMode, ioMode, "inherit"],
|
|
59488
|
-
stdio:
|
|
59481
|
+
stdio: opts.silent ? "pipe" : "inherit",
|
|
59489
59482
|
env: {
|
|
59490
59483
|
...process.env,
|
|
59491
|
-
...opts
|
|
59484
|
+
...opts.env
|
|
59492
59485
|
},
|
|
59493
|
-
cwd: opts
|
|
59486
|
+
cwd: opts.cwd
|
|
59494
59487
|
});
|
|
59495
59488
|
let output = ``;
|
|
59496
|
-
if (opts
|
|
59489
|
+
if (opts.captureOutput ?? opts.silent) {
|
|
59497
59490
|
cmd.stdout?.on("data", (data) => {
|
|
59498
59491
|
output += data;
|
|
59499
59492
|
});
|
|
@@ -59503,12 +59496,24 @@ var runCommand = async (command2, opts) => {
|
|
|
59503
59496
|
}
|
|
59504
59497
|
return new Promise((resolve9, reject) => {
|
|
59505
59498
|
cmd.on("close", (code) => {
|
|
59506
|
-
|
|
59507
|
-
|
|
59508
|
-
|
|
59509
|
-
|
|
59499
|
+
try {
|
|
59500
|
+
if (code !== 0) {
|
|
59501
|
+
throw new Error(output, { cause: code });
|
|
59502
|
+
}
|
|
59503
|
+
const transformOutput = opts.transformOutput ?? ((result) => result);
|
|
59504
|
+
const processedOutput = transformOutput(stripAnsi(output));
|
|
59505
|
+
resolve9(processedOutput);
|
|
59506
|
+
} catch (e) {
|
|
59507
|
+
if (opts.fallbackOutput) {
|
|
59508
|
+
resolve9(opts.fallbackOutput(e));
|
|
59509
|
+
} else {
|
|
59510
|
+
reject(new Error(output, { cause: e }));
|
|
59511
|
+
}
|
|
59510
59512
|
}
|
|
59511
59513
|
});
|
|
59514
|
+
cmd.on("error", (code) => {
|
|
59515
|
+
reject(code);
|
|
59516
|
+
});
|
|
59512
59517
|
});
|
|
59513
59518
|
}
|
|
59514
59519
|
});
|
|
@@ -59519,9 +59524,11 @@ async function runCommands({ commands, ...opts }) {
|
|
|
59519
59524
|
startText: opts.startText,
|
|
59520
59525
|
doneText: opts.doneText,
|
|
59521
59526
|
async promise() {
|
|
59527
|
+
const results = [];
|
|
59522
59528
|
for (const command2 of commands) {
|
|
59523
|
-
await runCommand(command2, { ...opts, useSpinner: false });
|
|
59529
|
+
results.push(await runCommand(command2, { ...opts, useSpinner: false }));
|
|
59524
59530
|
}
|
|
59531
|
+
return results.join("\n");
|
|
59525
59532
|
}
|
|
59526
59533
|
});
|
|
59527
59534
|
}
|
|
@@ -59538,8 +59545,9 @@ var printAsyncStatus = async ({
|
|
|
59538
59545
|
promise = promise();
|
|
59539
59546
|
}
|
|
59540
59547
|
try {
|
|
59541
|
-
await promise;
|
|
59542
|
-
|
|
59548
|
+
const output = await promise;
|
|
59549
|
+
const doneText = typeof opts.doneText === "function" ? opts.doneText(output) : opts.doneText;
|
|
59550
|
+
s?.stop(doneText);
|
|
59543
59551
|
} catch (err) {
|
|
59544
59552
|
s?.stop(err.message);
|
|
59545
59553
|
} finally {
|
|
@@ -59616,10 +59624,14 @@ var installWrangler = async () => {
|
|
|
59616
59624
|
};
|
|
59617
59625
|
var isLoggedIn = async () => {
|
|
59618
59626
|
const { npx: npx6 } = detectPackageManager();
|
|
59619
|
-
|
|
59620
|
-
|
|
59621
|
-
|
|
59622
|
-
|
|
59627
|
+
try {
|
|
59628
|
+
const output = await runCommand(`${npx6} wrangler whoami`, {
|
|
59629
|
+
silent: true
|
|
59630
|
+
});
|
|
59631
|
+
return /You are logged in/.test(output);
|
|
59632
|
+
} catch (error) {
|
|
59633
|
+
return false;
|
|
59634
|
+
}
|
|
59623
59635
|
};
|
|
59624
59636
|
var wranglerLogin = async () => {
|
|
59625
59637
|
const { npx: npx6 } = detectPackageManager();
|
|
@@ -59652,6 +59664,24 @@ var listAccounts = async () => {
|
|
|
59652
59664
|
});
|
|
59653
59665
|
return accounts;
|
|
59654
59666
|
};
|
|
59667
|
+
async function getWorkerdCompatibilityDate() {
|
|
59668
|
+
const { npm: npm12 } = detectPackageManager();
|
|
59669
|
+
return runCommand(`${npm12} info workerd dist-tags.latest`, {
|
|
59670
|
+
silent: true,
|
|
59671
|
+
captureOutput: true,
|
|
59672
|
+
startText: "Retrieving current workerd compatibility date",
|
|
59673
|
+
transformOutput: (result) => {
|
|
59674
|
+
const match = result.match(/\d+\.(\d{4})(\d{2})(\d{2})\.\d+/);
|
|
59675
|
+
if (!match) {
|
|
59676
|
+
throw new Error("Could not find workerd date");
|
|
59677
|
+
}
|
|
59678
|
+
const [, year, month, date] = match;
|
|
59679
|
+
return `${year}-${month}-${date}`;
|
|
59680
|
+
},
|
|
59681
|
+
fallbackOutput: () => "2023-05-18",
|
|
59682
|
+
doneText: (output) => `${brandColor("compatibility date")} ${dim(output)}`
|
|
59683
|
+
});
|
|
59684
|
+
}
|
|
59655
59685
|
|
|
59656
59686
|
// src/helpers/poll.ts
|
|
59657
59687
|
var import_promises = require("node:dns/promises");
|
|
@@ -59729,14 +59759,15 @@ var validateProjectDirectory = (relativePath) => {
|
|
|
59729
59759
|
const existsAlready = (0, import_fs6.existsSync)(path3);
|
|
59730
59760
|
const isEmpty = existsAlready && (0, import_fs6.readdirSync)(path3).length === 0;
|
|
59731
59761
|
if (existsAlready && !isEmpty) {
|
|
59732
|
-
|
|
59733
|
-
`Directory \`${relativePath}\` already exists and is not empty. Please choose a new name.`
|
|
59734
|
-
);
|
|
59762
|
+
return `Directory \`${relativePath}\` already exists and is not empty. Please choose a new name.`;
|
|
59735
59763
|
}
|
|
59736
59764
|
};
|
|
59737
59765
|
var setupProjectDirectory = (args) => {
|
|
59738
59766
|
const path3 = (0, import_path6.resolve)(args.projectName);
|
|
59739
|
-
validateProjectDirectory(path3);
|
|
59767
|
+
const err = validateProjectDirectory(path3);
|
|
59768
|
+
if (err) {
|
|
59769
|
+
crash(err);
|
|
59770
|
+
}
|
|
59740
59771
|
const directory = (0, import_path6.dirname)(path3);
|
|
59741
59772
|
const name = (0, import_path6.basename)(path3);
|
|
59742
59773
|
(0, import_fs6.mkdirSync)(directory, { recursive: true });
|
|
@@ -59745,14 +59776,12 @@ var setupProjectDirectory = (args) => {
|
|
|
59745
59776
|
};
|
|
59746
59777
|
var offerToDeploy = async (ctx) => {
|
|
59747
59778
|
startSection(`Deploy with Cloudflare`, `Step 3 of 3`);
|
|
59748
|
-
ctx.
|
|
59779
|
+
const label = `deploy via \`${npm} run ${ctx.framework?.config.deployCommand ?? "deploy"}\``;
|
|
59780
|
+
ctx.args.deploy = await processArgument(ctx.args, "deploy", {
|
|
59781
|
+
type: "confirm",
|
|
59749
59782
|
question: "Do you want to deploy your application?",
|
|
59750
|
-
|
|
59751
|
-
|
|
59752
|
-
)}`,
|
|
59753
|
-
defaultValue: ctx.args.deploy ?? (ctx.args.wranglerDefaults ? false : true),
|
|
59754
|
-
// if --wrangler-defaults, default to false, otherwise default to true
|
|
59755
|
-
acceptDefault: ctx.args.wranglerDefaults
|
|
59783
|
+
label,
|
|
59784
|
+
defaultValue: C3_DEFAULTS.deploy
|
|
59756
59785
|
});
|
|
59757
59786
|
if (!ctx.args.deploy)
|
|
59758
59787
|
return;
|
|
@@ -59806,14 +59835,12 @@ var chooseAccount = async (ctx) => {
|
|
|
59806
59835
|
label: name,
|
|
59807
59836
|
value: id
|
|
59808
59837
|
}));
|
|
59809
|
-
accountId = await
|
|
59838
|
+
accountId = await inputPrompt({
|
|
59839
|
+
type: "select",
|
|
59810
59840
|
question: "Which account do you want to use?",
|
|
59811
59841
|
options: accountOptions,
|
|
59812
|
-
|
|
59813
|
-
|
|
59814
|
-
},
|
|
59815
|
-
defaultValue: accountOptions[0].value,
|
|
59816
|
-
acceptDefault: ctx.args.wranglerDefaults
|
|
59842
|
+
label: "account",
|
|
59843
|
+
defaultValue: accountOptions[0].value
|
|
59817
59844
|
});
|
|
59818
59845
|
}
|
|
59819
59846
|
const accountName = Object.keys(accounts).find(
|
|
@@ -59823,6 +59850,7 @@ var chooseAccount = async (ctx) => {
|
|
|
59823
59850
|
};
|
|
59824
59851
|
var printSummary = async (ctx) => {
|
|
59825
59852
|
const nextSteps = [
|
|
59853
|
+
[`Navigate to the new directory`, `cd ${ctx.project.name}`],
|
|
59826
59854
|
[
|
|
59827
59855
|
`Run the development server`,
|
|
59828
59856
|
`${npm} run ${ctx.framework?.config.devCommand ?? "start"}`
|
|
@@ -59885,11 +59913,11 @@ var offerGit = async (ctx) => {
|
|
|
59885
59913
|
const insideGitRepo = await isInsideGitRepo(ctx.project.path);
|
|
59886
59914
|
if (insideGitRepo)
|
|
59887
59915
|
return;
|
|
59888
|
-
ctx.args.git
|
|
59916
|
+
ctx.args.git = await processArgument(ctx.args, "git", {
|
|
59917
|
+
type: "confirm",
|
|
59889
59918
|
question: "Do you want to use git for version control?",
|
|
59890
|
-
|
|
59891
|
-
defaultValue:
|
|
59892
|
-
acceptDefault: ctx.args.wranglerDefaults
|
|
59919
|
+
label: "git",
|
|
59920
|
+
defaultValue: C3_DEFAULTS.git
|
|
59893
59921
|
});
|
|
59894
59922
|
if (ctx.args.git) {
|
|
59895
59923
|
await printAsyncStatus({
|
|
@@ -59949,6 +59977,24 @@ async function initializeGit(cwd) {
|
|
|
59949
59977
|
await runCommand(`git init`, { useSpinner: false, silent: true, cwd });
|
|
59950
59978
|
}
|
|
59951
59979
|
}
|
|
59980
|
+
async function getProductionBranch(cwd) {
|
|
59981
|
+
try {
|
|
59982
|
+
const productionBranch = await runCommand(
|
|
59983
|
+
// "git branch --show-current", // git@^2.22
|
|
59984
|
+
"git rev-parse --abbrev-ref HEAD",
|
|
59985
|
+
// git@^1.6.3
|
|
59986
|
+
{
|
|
59987
|
+
silent: true,
|
|
59988
|
+
cwd,
|
|
59989
|
+
useSpinner: false,
|
|
59990
|
+
captureOutput: true
|
|
59991
|
+
}
|
|
59992
|
+
);
|
|
59993
|
+
return productionBranch.trim();
|
|
59994
|
+
} catch (err) {
|
|
59995
|
+
}
|
|
59996
|
+
return "main";
|
|
59997
|
+
}
|
|
59952
59998
|
|
|
59953
59999
|
// src/pages.ts
|
|
59954
60000
|
var import_path8 = require("path");
|
|
@@ -60021,10 +60067,10 @@ var config = {
|
|
|
60021
60067
|
displayName: "Angular",
|
|
60022
60068
|
packageScripts: {
|
|
60023
60069
|
process: "node ./tools/copy-worker-files.mjs && node ./tools/copy-client-files.mjs && node ./tools/bundle.mjs",
|
|
60024
|
-
prestart: `${npm2} run build:ssr &&
|
|
60070
|
+
prestart: `${npm2} run build:ssr && ${npm2} run process`,
|
|
60025
60071
|
start: "wrangler pages dev dist/cloudflare --compatibility-date=2021-09-20 --experimental-local",
|
|
60026
|
-
predeploy: `${npm2} run build:ssr &&
|
|
60027
|
-
deploy: "wrangler pages
|
|
60072
|
+
predeploy: `${npm2} run build:ssr && ${npm2} run process`,
|
|
60073
|
+
deploy: "wrangler pages deploy dist/cloudflare"
|
|
60028
60074
|
},
|
|
60029
60075
|
deployCommand: "deploy",
|
|
60030
60076
|
devCommand: "start"
|
|
@@ -60119,7 +60165,7 @@ var config2 = {
|
|
|
60119
60165
|
displayName: "Astro",
|
|
60120
60166
|
packageScripts: {
|
|
60121
60167
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- astro dev`,
|
|
60122
|
-
"pages:deploy": `astro build && wrangler pages
|
|
60168
|
+
"pages:deploy": `astro build && wrangler pages deploy ./dist`
|
|
60123
60169
|
},
|
|
60124
60170
|
testFlags: [
|
|
60125
60171
|
"--skip-houston",
|
|
@@ -60148,7 +60194,7 @@ var config3 = {
|
|
|
60148
60194
|
displayName: "Docusaurus",
|
|
60149
60195
|
packageScripts: {
|
|
60150
60196
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- ${npm3} run start`,
|
|
60151
|
-
"pages:deploy": `NODE_VERSION=16 ${npm3} run build && wrangler pages
|
|
60197
|
+
"pages:deploy": `NODE_VERSION=16 ${npm3} run build && wrangler pages deploy ./build`
|
|
60152
60198
|
}
|
|
60153
60199
|
};
|
|
60154
60200
|
var docusaurus_default = config3;
|
|
@@ -60157,25 +60203,19 @@ var docusaurus_default = config3;
|
|
|
60157
60203
|
var { npm: npm4, dlx: dlx4 } = detectPackageManager();
|
|
60158
60204
|
var generate4 = async (ctx) => {
|
|
60159
60205
|
const defaultTemplate = "https://github.com/gatsbyjs/gatsby-starter-blog";
|
|
60160
|
-
const useTemplate = await
|
|
60206
|
+
const useTemplate = await inputPrompt({
|
|
60207
|
+
type: "confirm",
|
|
60161
60208
|
question: "Would you like to use a template?",
|
|
60162
|
-
|
|
60163
|
-
|
|
60164
|
-
return `${brandColor(`template`)} ${status2}`;
|
|
60165
|
-
},
|
|
60166
|
-
defaultValue: true,
|
|
60167
|
-
acceptDefault: false
|
|
60209
|
+
label: "template",
|
|
60210
|
+
defaultValue: true
|
|
60168
60211
|
});
|
|
60169
60212
|
let templateUrl = "";
|
|
60170
60213
|
if (useTemplate) {
|
|
60171
|
-
templateUrl = await
|
|
60214
|
+
templateUrl = await inputPrompt({
|
|
60215
|
+
type: "text",
|
|
60172
60216
|
question: `Please specify the url of the template you'd like to use`,
|
|
60173
|
-
|
|
60174
|
-
|
|
60175
|
-
return `${brandColor("template")} ${dim(result)}`;
|
|
60176
|
-
},
|
|
60177
|
-
defaultValue: defaultTemplate,
|
|
60178
|
-
acceptDefault: false
|
|
60217
|
+
label: "template",
|
|
60218
|
+
defaultValue: defaultTemplate
|
|
60179
60219
|
});
|
|
60180
60220
|
}
|
|
60181
60221
|
const version2 = getFrameworkVersion(ctx);
|
|
@@ -60189,7 +60229,7 @@ var config4 = {
|
|
|
60189
60229
|
displayName: "Gatsby",
|
|
60190
60230
|
packageScripts: {
|
|
60191
60231
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 8000 -- ${npm4} run develop`,
|
|
60192
|
-
"pages:deploy": `${npm4} run build && wrangler pages
|
|
60232
|
+
"pages:deploy": `${npm4} run build && wrangler pages deploy ./public`
|
|
60193
60233
|
}
|
|
60194
60234
|
};
|
|
60195
60235
|
var gatsby_default = config4;
|
|
@@ -60315,7 +60355,7 @@ var config6 = {
|
|
|
60315
60355
|
displayName: "Next",
|
|
60316
60356
|
packageScripts: {
|
|
60317
60357
|
"pages:build": `${npx3} @cloudflare/next-on-pages@1`,
|
|
60318
|
-
"pages:deploy": `${npm5} run pages:build && wrangler pages
|
|
60358
|
+
"pages:deploy": `${npm5} run pages:build && wrangler pages deploy .vercel/output/static`,
|
|
60319
60359
|
"pages:watch": `${npx3} @cloudflare/next-on-pages@1 --watch`,
|
|
60320
60360
|
"pages:dev": `${npx3} wrangler pages dev .vercel/output/static --compatibility-flag=nodejs_compat`
|
|
60321
60361
|
},
|
|
@@ -60353,7 +60393,7 @@ var config7 = {
|
|
|
60353
60393
|
displayName: "Nuxt",
|
|
60354
60394
|
packageScripts: {
|
|
60355
60395
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- npm run dev`,
|
|
60356
|
-
"pages:deploy": `NODE_VERSION=17 npm run generate && wrangler pages
|
|
60396
|
+
"pages:deploy": `NODE_VERSION=17 npm run generate && wrangler pages deploy ./dist`
|
|
60357
60397
|
}
|
|
60358
60398
|
};
|
|
60359
60399
|
var nuxt_default = config7;
|
|
@@ -60400,7 +60440,7 @@ var config9 = {
|
|
|
60400
60440
|
displayName: "React",
|
|
60401
60441
|
packageScripts: {
|
|
60402
60442
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --port 3000 -- ${npm7} start`,
|
|
60403
|
-
"pages:deploy": `${npm7} run build && wrangler pages
|
|
60443
|
+
"pages:deploy": `${npm7} run build && wrangler pages deploy ./build`
|
|
60404
60444
|
}
|
|
60405
60445
|
};
|
|
60406
60446
|
var react_default = config9;
|
|
@@ -60419,7 +60459,7 @@ var config10 = {
|
|
|
60419
60459
|
generate: generate10,
|
|
60420
60460
|
displayName: "Remix",
|
|
60421
60461
|
packageScripts: {
|
|
60422
|
-
"pages:deploy": `${npm8} run build && wrangler pages
|
|
60462
|
+
"pages:deploy": `${npm8} run build && wrangler pages deploy ./public`
|
|
60423
60463
|
},
|
|
60424
60464
|
devCommand: "dev",
|
|
60425
60465
|
testFlags: ["--typescript", "--no-install"]
|
|
@@ -60468,7 +60508,7 @@ var config11 = {
|
|
|
60468
60508
|
displayName: "Solid",
|
|
60469
60509
|
packageScripts: {
|
|
60470
60510
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- ${npm9} run dev`,
|
|
60471
|
-
"pages:deploy": `${npm9} run build
|
|
60511
|
+
"pages:deploy": `${npm9} run build && wrangler pages deploy ./dist/public`
|
|
60472
60512
|
}
|
|
60473
60513
|
};
|
|
60474
60514
|
var solid_default = config11;
|
|
@@ -60568,7 +60608,7 @@ var config12 = {
|
|
|
60568
60608
|
displayName: "Svelte",
|
|
60569
60609
|
packageScripts: {
|
|
60570
60610
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 5173 -- ${npm10} run dev`,
|
|
60571
|
-
"pages:deploy": `NODE_VERSION=16 ${npm10} run build && wrangler pages
|
|
60611
|
+
"pages:deploy": `NODE_VERSION=16 ${npm10} run build && wrangler pages deploy .svelte-kit/cloudflare`
|
|
60572
60612
|
}
|
|
60573
60613
|
};
|
|
60574
60614
|
var svelte_default = config12;
|
|
@@ -60579,7 +60619,7 @@ var versionMap_default = {
|
|
|
60579
60619
|
astro: "3.1.5",
|
|
60580
60620
|
docusaurus: "2.4.1",
|
|
60581
60621
|
gatsby: "5.10.0",
|
|
60582
|
-
hono: "0.2.
|
|
60622
|
+
hono: "0.2.6",
|
|
60583
60623
|
next: "13.4.2",
|
|
60584
60624
|
nuxt: "3.4.2",
|
|
60585
60625
|
qwik: "1.1.x",
|
|
@@ -60604,7 +60644,7 @@ var config13 = {
|
|
|
60604
60644
|
displayName: "Vue",
|
|
60605
60645
|
packageScripts: {
|
|
60606
60646
|
"pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 5173 -- ${npm11} run dev`,
|
|
60607
|
-
"pages:deploy": `${npm11} run build && wrangler pages
|
|
60647
|
+
"pages:deploy": `${npm11} run build && wrangler pages deploy ./dist`
|
|
60608
60648
|
},
|
|
60609
60649
|
testFlags: ["--ts"]
|
|
60610
60650
|
};
|
|
@@ -60684,14 +60724,12 @@ var getFrameworkSelection = async (args) => {
|
|
|
60684
60724
|
value: key
|
|
60685
60725
|
})
|
|
60686
60726
|
);
|
|
60687
|
-
const framework = await
|
|
60727
|
+
const framework = await processArgument(args, "framework", {
|
|
60728
|
+
type: "select",
|
|
60729
|
+
label: "framework",
|
|
60688
60730
|
question: "Which development framework do you want to use?",
|
|
60689
60731
|
options: frameworkOptions,
|
|
60690
|
-
|
|
60691
|
-
return `${brandColor("framework")} ${dim(option.label)}`;
|
|
60692
|
-
},
|
|
60693
|
-
defaultValue: args.framework ?? "svelte",
|
|
60694
|
-
acceptDefault: Boolean(args.framework)
|
|
60732
|
+
defaultValue: C3_DEFAULTS.framework
|
|
60695
60733
|
});
|
|
60696
60734
|
framework || crash("A framework must be selected to continue.");
|
|
60697
60735
|
if (!supportedFramework(framework)) {
|
|
@@ -60725,7 +60763,8 @@ var createProject = async (ctx) => {
|
|
|
60725
60763
|
const CLOUDFLARE_ACCOUNT_ID = ctx.account.id;
|
|
60726
60764
|
const compatFlags = ctx.framework?.config.compatibilityFlags?.join(" ");
|
|
60727
60765
|
const compatFlagsArg = compatFlags ? `--compatibility-flags ${compatFlags}` : "";
|
|
60728
|
-
const
|
|
60766
|
+
const productionBranch = await getProductionBranch(ctx.project.path);
|
|
60767
|
+
const cmd = `${npx5} wrangler pages project create ${ctx.project.name} --production-branch ${productionBranch} ${compatFlagsArg}`;
|
|
60729
60768
|
try {
|
|
60730
60769
|
await retry(
|
|
60731
60770
|
CREATE_PROJECT_RETRIES,
|
|
@@ -60734,7 +60773,7 @@ var createProject = async (ctx) => {
|
|
|
60734
60773
|
cwd: ctx.project.path,
|
|
60735
60774
|
env: { CLOUDFLARE_ACCOUNT_ID },
|
|
60736
60775
|
startText: "Creating Pages project",
|
|
60737
|
-
doneText: `${brandColor("created")} ${dim(`via \`${cmd}\``)}`
|
|
60776
|
+
doneText: `${brandColor("created")} ${dim(`via \`${cmd.trim()}\``)}`
|
|
60738
60777
|
})
|
|
60739
60778
|
);
|
|
60740
60779
|
} catch (error) {
|
|
@@ -60768,14 +60807,12 @@ var runWorkersGenerator = async (args) => {
|
|
|
60768
60807
|
await printSummary(ctx);
|
|
60769
60808
|
};
|
|
60770
60809
|
async function getTemplate(ctx) {
|
|
60771
|
-
|
|
60772
|
-
|
|
60773
|
-
|
|
60774
|
-
|
|
60775
|
-
|
|
60776
|
-
|
|
60777
|
-
});
|
|
60778
|
-
}
|
|
60810
|
+
ctx.args.ts = await processArgument(ctx.args, "ts", {
|
|
60811
|
+
type: "confirm",
|
|
60812
|
+
question: "Do you want to use TypeScript?",
|
|
60813
|
+
label: "typescript",
|
|
60814
|
+
defaultValue: C3_DEFAULTS.ts
|
|
60815
|
+
});
|
|
60779
60816
|
const preexisting = ctx.args.type === "pre-existing";
|
|
60780
60817
|
const template = preexisting ? "hello-world" : ctx.args.type;
|
|
60781
60818
|
const path3 = (0, import_path9.resolve)(
|
|
@@ -60799,12 +60836,16 @@ async function copyExistingWorkerFiles(ctx) {
|
|
|
60799
60836
|
if (preexisting) {
|
|
60800
60837
|
await chooseAccount(ctx);
|
|
60801
60838
|
if (ctx.args.existingScript === void 0) {
|
|
60802
|
-
ctx.args.existingScript = await
|
|
60803
|
-
|
|
60804
|
-
|
|
60805
|
-
|
|
60806
|
-
|
|
60807
|
-
|
|
60839
|
+
ctx.args.existingScript = await processArgument(
|
|
60840
|
+
ctx.args,
|
|
60841
|
+
"existingScript",
|
|
60842
|
+
{
|
|
60843
|
+
type: "text",
|
|
60844
|
+
question: "Please specify the name of the existing worker in this account?",
|
|
60845
|
+
label: "worker",
|
|
60846
|
+
defaultValue: ctx.project.name
|
|
60847
|
+
}
|
|
60848
|
+
);
|
|
60808
60849
|
}
|
|
60809
60850
|
const tempdir = await (0, import_promises3.mkdtemp)(
|
|
60810
60851
|
(0, import_path9.join)((0, import_os.tmpdir)(), "c3-wrangler-init--from-dash-")
|
|
@@ -60845,10 +60886,12 @@ async function updateFiles(ctx) {
|
|
|
60845
60886
|
packagejson: JSON.parse(await (0, import_promises3.readFile)(paths.packagejson, "utf-8")),
|
|
60846
60887
|
wranglertoml: await (0, import_promises3.readFile)(paths.wranglertoml, "utf-8")
|
|
60847
60888
|
};
|
|
60848
|
-
contents.packagejson.name
|
|
60849
|
-
|
|
60850
|
-
|
|
60851
|
-
|
|
60889
|
+
if (contents.packagejson.name === "<TBD>") {
|
|
60890
|
+
contents.packagejson.name = ctx.project.name;
|
|
60891
|
+
}
|
|
60892
|
+
contents.wranglertoml = contents.wranglertoml.replace(/^name\s*=\s*"<TBD>"/m, `name = "${ctx.project.name}"`).replace(
|
|
60893
|
+
/^compatibility_date\s*=\s*"<TBD>"/m,
|
|
60894
|
+
`compatibility_date = "${await getWorkerdCompatibilityDate()}"`
|
|
60852
60895
|
);
|
|
60853
60896
|
await (0, import_promises3.writeFile)(
|
|
60854
60897
|
paths.packagejson,
|
|
@@ -60858,19 +60901,55 @@ async function updateFiles(ctx) {
|
|
|
60858
60901
|
}
|
|
60859
60902
|
|
|
60860
60903
|
// src/cli.ts
|
|
60904
|
+
var C3_DEFAULTS = {
|
|
60905
|
+
projectName: new import_haikunator.default().haikunate({ tokenHex: true }),
|
|
60906
|
+
type: "hello-world",
|
|
60907
|
+
framework: "angular",
|
|
60908
|
+
deploy: true,
|
|
60909
|
+
git: true,
|
|
60910
|
+
open: true,
|
|
60911
|
+
ts: true
|
|
60912
|
+
};
|
|
60913
|
+
var WRANGLER_DEFAULTS = {
|
|
60914
|
+
...C3_DEFAULTS,
|
|
60915
|
+
deploy: false
|
|
60916
|
+
};
|
|
60861
60917
|
var main = async (argv) => {
|
|
60862
|
-
printBanner();
|
|
60863
60918
|
const args = await parseArgs(argv);
|
|
60919
|
+
printBanner();
|
|
60920
|
+
const projectName = await processArgument(args, "projectName", {
|
|
60921
|
+
type: "text",
|
|
60922
|
+
question: `In which directory do you want to create your application?`,
|
|
60923
|
+
helpText: "also used as application name",
|
|
60924
|
+
defaultValue: C3_DEFAULTS.projectName,
|
|
60925
|
+
label: "dir",
|
|
60926
|
+
validate: (value) => validateProjectDirectory(String(value) || C3_DEFAULTS.projectName),
|
|
60927
|
+
format: (val) => `./${val}`
|
|
60928
|
+
});
|
|
60929
|
+
if (!args.type) {
|
|
60930
|
+
if (args.framework) {
|
|
60931
|
+
args.type = "webFramework";
|
|
60932
|
+
} else if (args.existingScript) {
|
|
60933
|
+
args.type = "pre-existing";
|
|
60934
|
+
}
|
|
60935
|
+
}
|
|
60936
|
+
const templateOptions = Object.entries(templateMap).filter(([_3, { hidden: hidden2 }]) => !hidden2).map(([value, { label }]) => ({ value, label }));
|
|
60937
|
+
const type = await processArgument(args, "type", {
|
|
60938
|
+
type: "select",
|
|
60939
|
+
question: "What type of application do you want to create?",
|
|
60940
|
+
label: "type",
|
|
60941
|
+
options: templateOptions,
|
|
60942
|
+
defaultValue: C3_DEFAULTS.type
|
|
60943
|
+
});
|
|
60944
|
+
if (!type || !Object.keys(templateMap).includes(type)) {
|
|
60945
|
+
return crash("An application type must be specified to continue.");
|
|
60946
|
+
}
|
|
60864
60947
|
const validatedArgs = {
|
|
60865
60948
|
...args,
|
|
60866
|
-
|
|
60867
|
-
|
|
60868
|
-
}),
|
|
60869
|
-
type: await validateType(args.type, {
|
|
60870
|
-
acceptDefault: args.wranglerDefaults
|
|
60871
|
-
})
|
|
60949
|
+
type,
|
|
60950
|
+
projectName
|
|
60872
60951
|
};
|
|
60873
|
-
const { handler } = templateMap[
|
|
60952
|
+
const { handler } = templateMap[type];
|
|
60874
60953
|
await handler(validatedArgs);
|
|
60875
60954
|
};
|
|
60876
60955
|
var printBanner = () => {
|
|
@@ -60887,41 +60966,17 @@ var parseArgs = async (argv) => {
|
|
|
60887
60966
|
}).option("existing-script", {
|
|
60888
60967
|
type: "string",
|
|
60889
60968
|
hidden: templateMap["pre-existing"].hidden
|
|
60890
|
-
}).option("
|
|
60969
|
+
}).option("accept-defaults", {
|
|
60970
|
+
alias: "y",
|
|
60971
|
+
type: "boolean"
|
|
60972
|
+
}).option("wrangler-defaults", { type: "boolean", hidden: true }).version(version).help().argv;
|
|
60891
60973
|
return {
|
|
60974
|
+
...args.wranglerDefaults && WRANGLER_DEFAULTS,
|
|
60975
|
+
...args.acceptDefaults && C3_DEFAULTS,
|
|
60892
60976
|
projectName: args._[0],
|
|
60893
60977
|
...args
|
|
60894
60978
|
};
|
|
60895
60979
|
};
|
|
60896
|
-
var validateName = async (name, { acceptDefault = false } = {}) => {
|
|
60897
|
-
const defaultValue = name ?? new import_haikunator.default().haikunate({ tokenHex: true });
|
|
60898
|
-
return textInput({
|
|
60899
|
-
question: `Where do you want to create your application?`,
|
|
60900
|
-
helpText: "also used as application name",
|
|
60901
|
-
renderSubmitted: (value) => {
|
|
60902
|
-
return `${brandColor("dir")} ${dim(value)}`;
|
|
60903
|
-
},
|
|
60904
|
-
defaultValue,
|
|
60905
|
-
acceptDefault,
|
|
60906
|
-
validate: (value = defaultValue) => validateProjectDirectory(value)
|
|
60907
|
-
});
|
|
60908
|
-
};
|
|
60909
|
-
var validateType = async (type, { acceptDefault = false } = {}) => {
|
|
60910
|
-
const templateOptions = Object.entries(templateMap).filter(([_3, { hidden: hidden2 }]) => !hidden2).map(([value, { label }]) => ({ value, label }));
|
|
60911
|
-
type = await selectInput({
|
|
60912
|
-
question: "What type of application do you want to create?",
|
|
60913
|
-
options: templateOptions,
|
|
60914
|
-
renderSubmitted: (option) => {
|
|
60915
|
-
return `${brandColor("type")} ${dim(option.label)}`;
|
|
60916
|
-
},
|
|
60917
|
-
defaultValue: type ?? "hello-world",
|
|
60918
|
-
acceptDefault
|
|
60919
|
-
});
|
|
60920
|
-
if (!type || !Object.keys(templateMap).includes(type)) {
|
|
60921
|
-
crash("An application type must be specified to continue.");
|
|
60922
|
-
}
|
|
60923
|
-
return type;
|
|
60924
|
-
};
|
|
60925
60980
|
var templateMap = {
|
|
60926
60981
|
webFramework: {
|
|
60927
60982
|
label: "Website or web app",
|
|
@@ -60959,7 +61014,9 @@ var templateMap = {
|
|
|
60959
61014
|
main(process.argv).catch((e) => crash(e));
|
|
60960
61015
|
// Annotate the CommonJS export names for ESM import in node:
|
|
60961
61016
|
0 && (module.exports = {
|
|
60962
|
-
|
|
61017
|
+
C3_DEFAULTS,
|
|
61018
|
+
main,
|
|
61019
|
+
parseArgs
|
|
60963
61020
|
});
|
|
60964
61021
|
/*! Bundled license information:
|
|
60965
61022
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cloudflare",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-ec358f4f",
|
|
4
4
|
"description": "A CLI for creating and deploying new applications to Cloudflare.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"recast": "^0.22.0",
|
|
62
62
|
"semver": "^7.5.1",
|
|
63
63
|
"typescript": "^5.0.2",
|
|
64
|
-
"undici": "
|
|
64
|
+
"undici": "5.20.0",
|
|
65
65
|
"vite-tsconfig-paths": "^4.0.8",
|
|
66
66
|
"vitest": "^0.30.0",
|
|
67
67
|
"which-pm-runs": "^1.1.0",
|
|
@@ -12,7 +12,7 @@ The sample plugin allows ChatGPT users to search for repositories using GitHub's
|
|
|
12
12
|
1. Install [wrangler](https://developers.cloudflare.com/workers/cli-wrangler/install-update), the Cloudflare Workers CLI
|
|
13
13
|
2. Clone this project and install dependencies with `npm install`
|
|
14
14
|
3. Run `wrangler login` to login to your Cloudflare account in wrangler
|
|
15
|
-
4. Run `wrangler
|
|
15
|
+
4. Run `wrangler deploy` to publish the plugin to Cloudflare Workers
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
name = "
|
|
1
|
+
name = "<TBD>"
|
|
2
2
|
main = "src/index.ts"
|
|
3
|
-
compatibility_date = "
|
|
3
|
+
compatibility_date = "<TBD>"
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
|
-
"deploy": "wrangler
|
|
6
|
+
"deploy": "wrangler deploy",
|
|
7
7
|
"start": "wrangler dev"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@cloudflare/workers-types": "^4.20230419.0",
|
|
11
10
|
"itty-router": "^3.0.12",
|
|
12
11
|
"wrangler": "^3.0.0"
|
|
13
12
|
}
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
|
-
"deploy": "wrangler
|
|
6
|
+
"deploy": "wrangler deploy",
|
|
7
7
|
"start": "wrangler dev"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@cloudflare/workers-types": "^4.20230419.0",
|
|
11
|
-
"typescript": "^5.0.4",
|
|
12
10
|
"wrangler": "^3.0.0"
|
|
13
11
|
}
|
|
14
12
|
}
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
|
-
"deploy": "wrangler
|
|
6
|
+
"deploy": "wrangler deploy",
|
|
7
7
|
"start": "wrangler dev"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@cloudflare/workers-types": "^4.20230419.0",
|
|
11
|
-
"typescript": "^5.0.4",
|
|
12
10
|
"wrangler": "^3.0.0"
|
|
13
11
|
}
|
|
14
12
|
}
|
|
@@ -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
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
|
-
"deploy": "wrangler
|
|
6
|
+
"deploy": "wrangler deploy",
|
|
7
7
|
"start": "wrangler dev"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@cloudflare/workers-types": "^4.20230419.0",
|
|
11
|
-
"typescript": "^5.0.4",
|
|
12
10
|
"wrangler": "^3.0.0"
|
|
13
11
|
}
|
|
14
12
|
}
|