create-cloudflare 0.0.0-d4eb5c59 → 0.0.0-d55eeca8
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 +193 -139
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/templates/angular/c3.ts +1 -0
- package/templates/hello-world/c3.ts +4 -1
- package/templates/hello-world/ts/tsconfig.json +2 -1
- package/templates/hello-world-durable-object/c3.ts +1 -1
- package/templates/next/README.md +1 -1
- package/templates/next/c3.ts +1 -1
- package/templates/openapi/ts/README.md +3 -3
- package/templates/openapi/ts/package.json +3 -1
- package/templates/openapi/ts/src/endpoints/taskCreate.ts +26 -16
- package/templates/openapi/ts/src/endpoints/taskDelete.ts +20 -19
- package/templates/openapi/ts/src/endpoints/taskFetch.ts +30 -23
- package/templates/openapi/ts/src/endpoints/taskList.ts +27 -24
- package/templates/openapi/ts/src/index.ts +14 -20
- package/templates/openapi/ts/src/types.ts +9 -8
- package/templates/hello-world-python/c3.ts +0 -9
- /package/templates/{hello-world-python → hello-world}/py/__dot__gitignore +0 -0
- /package/templates/{hello-world-python → hello-world}/py/package.json +0 -0
- /package/templates/{hello-world-python → hello-world}/py/src/entry.py +0 -0
- /package/templates/{hello-world-python → hello-world}/py/wrangler.toml +0 -0
package/dist/cli.js
CHANGED
|
@@ -2870,7 +2870,7 @@ var init_args = __esm({
|
|
|
2870
2870
|
var version;
|
|
2871
2871
|
var init_package = __esm({
|
|
2872
2872
|
"package.json"() {
|
|
2873
|
-
version = "0.0.0-
|
|
2873
|
+
version = "0.0.0-d55eeca8";
|
|
2874
2874
|
}
|
|
2875
2875
|
});
|
|
2876
2876
|
|
|
@@ -23653,13 +23653,14 @@ var init_cli2 = __esm({
|
|
|
23653
23653
|
};
|
|
23654
23654
|
C3_DEFAULTS = {
|
|
23655
23655
|
projectName: new import_haikunator.default().haikunate({ tokenHex: true }),
|
|
23656
|
+
category: "hello-world",
|
|
23656
23657
|
type: "hello-world",
|
|
23657
23658
|
framework: "analog",
|
|
23658
23659
|
autoUpdate: true,
|
|
23659
23660
|
deploy: true,
|
|
23660
23661
|
git: true,
|
|
23661
23662
|
open: true,
|
|
23662
|
-
|
|
23663
|
+
lang: "ts",
|
|
23663
23664
|
template: "cloudflare/workers-sdk/packages/create-cloudflare/templates/hello-world"
|
|
23664
23665
|
};
|
|
23665
23666
|
WRANGLER_DEFAULTS = {
|
|
@@ -23684,17 +23685,17 @@ var init_package2 = __esm({
|
|
|
23684
23685
|
dependencies: {
|
|
23685
23686
|
"create-astro": "4.8.0",
|
|
23686
23687
|
"create-analog": "1.3.1",
|
|
23687
|
-
"@angular/create": "18.
|
|
23688
|
+
"@angular/create": "18.1.2",
|
|
23688
23689
|
"create-docusaurus": "3.4.0",
|
|
23689
|
-
"create-hono": "0.
|
|
23690
|
-
"create-next-app": "14.
|
|
23690
|
+
"create-hono": "0.10.1",
|
|
23691
|
+
"create-next-app": "14.2.5",
|
|
23691
23692
|
"create-qwik": "1.5.7",
|
|
23692
23693
|
"create-react-app": "5.0.1",
|
|
23693
|
-
"create-remix": "2.
|
|
23694
|
-
"create-solid": "0.5.
|
|
23695
|
-
"create-svelte": "6.3.
|
|
23694
|
+
"create-remix": "2.10.3",
|
|
23695
|
+
"create-solid": "0.5.12",
|
|
23696
|
+
"create-svelte": "6.3.4",
|
|
23696
23697
|
"create-vue": "3.10.4",
|
|
23697
|
-
gatsby: "5.13.
|
|
23698
|
+
gatsby: "5.13.7",
|
|
23698
23699
|
nuxi: "3.12.0"
|
|
23699
23700
|
},
|
|
23700
23701
|
frameworkCliMap: {
|
|
@@ -23771,7 +23772,7 @@ var init_frameworks = __esm({
|
|
|
23771
23772
|
var version2;
|
|
23772
23773
|
var init_package3 = __esm({
|
|
23773
23774
|
"../wrangler/package.json"() {
|
|
23774
|
-
version2 = "0.0.0-
|
|
23775
|
+
version2 = "0.0.0-d55eeca8";
|
|
23775
23776
|
}
|
|
23776
23777
|
});
|
|
23777
23778
|
|
|
@@ -23884,16 +23885,6 @@ var init_git = __esm({
|
|
|
23884
23885
|
ctx.args.git = false;
|
|
23885
23886
|
return;
|
|
23886
23887
|
}
|
|
23887
|
-
const gitConfigured = await isGitConfigured();
|
|
23888
|
-
if (!gitConfigured) {
|
|
23889
|
-
if (ctx.args.git) {
|
|
23890
|
-
updateStatus(
|
|
23891
|
-
"Must configure `user.name` and user.email` to use git. Continuing without git."
|
|
23892
|
-
);
|
|
23893
|
-
}
|
|
23894
|
-
ctx.args.git = false;
|
|
23895
|
-
return;
|
|
23896
|
-
}
|
|
23897
23888
|
const insideGitRepo = await isInsideGitRepo(ctx.project.path);
|
|
23898
23889
|
if (insideGitRepo) {
|
|
23899
23890
|
ctx.args.git = true;
|
|
@@ -23905,9 +23896,18 @@ var init_git = __esm({
|
|
|
23905
23896
|
label: "git",
|
|
23906
23897
|
defaultValue: C3_DEFAULTS.git
|
|
23907
23898
|
});
|
|
23908
|
-
if (ctx.args.git) {
|
|
23909
|
-
|
|
23899
|
+
if (!ctx.args.git) {
|
|
23900
|
+
return;
|
|
23910
23901
|
}
|
|
23902
|
+
const gitConfigured = await isGitConfigured();
|
|
23903
|
+
if (!gitConfigured) {
|
|
23904
|
+
updateStatus(
|
|
23905
|
+
"Must configure `user.name` and user.email` to use git. Continuing without git."
|
|
23906
|
+
);
|
|
23907
|
+
ctx.args.git = false;
|
|
23908
|
+
return;
|
|
23909
|
+
}
|
|
23910
|
+
await initializeGit(ctx.project.path);
|
|
23911
23911
|
};
|
|
23912
23912
|
gitCommit = async (ctx) => {
|
|
23913
23913
|
const commitMessage = await createCommitMessage(ctx);
|
|
@@ -70009,6 +70009,7 @@ async function updateAppCode() {
|
|
|
70009
70009
|
const packageManifest = readJSON(packageJsonPath);
|
|
70010
70010
|
delete packageManifest["dependencies"]["@angular/ssr"];
|
|
70011
70011
|
delete packageManifest["dependencies"]["express"];
|
|
70012
|
+
delete packageManifest["devDependencies"]["@types/express"];
|
|
70012
70013
|
writeFile2(packageJsonPath, JSON.stringify(packageManifest, null, 2));
|
|
70013
70014
|
s.stop(`${brandColor(`updated`)} ${dim(`\`package.json\``)}`);
|
|
70014
70015
|
}
|
|
@@ -70372,7 +70373,7 @@ ${$1}`
|
|
|
70372
70373
|
|
|
70373
70374
|
// Here we use the @cloudflare/next-on-pages next-dev module to allow us to use bindings during local development
|
|
70374
70375
|
// (when running the application with \`next dev\`), for more information see:
|
|
70375
|
-
// https://github.com/cloudflare/next-on-pages/blob/
|
|
70376
|
+
// https://github.com/cloudflare/next-on-pages/blob/main/internal-packages/next-dev/README.md
|
|
70376
70377
|
if (process.env.NODE_ENV === 'development') {
|
|
70377
70378
|
await setupDevPlatform();
|
|
70378
70379
|
}
|
|
@@ -71100,7 +71101,7 @@ var init_c315 = __esm({
|
|
|
71100
71101
|
c3_default15 = {
|
|
71101
71102
|
configVersion: 1,
|
|
71102
71103
|
id: "hello-world",
|
|
71103
|
-
displayName:
|
|
71104
|
+
displayName: "Hello World Worker",
|
|
71104
71105
|
platform: "workers",
|
|
71105
71106
|
copyFiles: {
|
|
71106
71107
|
variants: {
|
|
@@ -71109,6 +71110,9 @@ var init_c315 = __esm({
|
|
|
71109
71110
|
},
|
|
71110
71111
|
ts: {
|
|
71111
71112
|
path: "./ts"
|
|
71113
|
+
},
|
|
71114
|
+
python: {
|
|
71115
|
+
path: "./py"
|
|
71112
71116
|
}
|
|
71113
71117
|
}
|
|
71114
71118
|
}
|
|
@@ -71116,35 +71120,15 @@ var init_c315 = __esm({
|
|
|
71116
71120
|
}
|
|
71117
71121
|
});
|
|
71118
71122
|
|
|
71119
|
-
// templates/
|
|
71123
|
+
// templates/common/c3.ts
|
|
71120
71124
|
var c3_exports16 = {};
|
|
71121
71125
|
__export(c3_exports16, {
|
|
71122
71126
|
default: () => c3_default16
|
|
71123
71127
|
});
|
|
71124
71128
|
var c3_default16;
|
|
71125
71129
|
var init_c316 = __esm({
|
|
71126
|
-
"templates/hello-world-python/c3.ts"() {
|
|
71127
|
-
c3_default16 = {
|
|
71128
|
-
configVersion: 1,
|
|
71129
|
-
id: "hello-world-python",
|
|
71130
|
-
displayName: '"Hello World" Worker (Python)',
|
|
71131
|
-
platform: "workers",
|
|
71132
|
-
copyFiles: {
|
|
71133
|
-
path: "./py"
|
|
71134
|
-
}
|
|
71135
|
-
};
|
|
71136
|
-
}
|
|
71137
|
-
});
|
|
71138
|
-
|
|
71139
|
-
// templates/common/c3.ts
|
|
71140
|
-
var c3_exports17 = {};
|
|
71141
|
-
__export(c3_exports17, {
|
|
71142
|
-
default: () => c3_default17
|
|
71143
|
-
});
|
|
71144
|
-
var c3_default17;
|
|
71145
|
-
var init_c317 = __esm({
|
|
71146
71130
|
"templates/common/c3.ts"() {
|
|
71147
|
-
|
|
71131
|
+
c3_default16 = {
|
|
71148
71132
|
configVersion: 1,
|
|
71149
71133
|
id: "common",
|
|
71150
71134
|
displayName: "Example router & proxy Worker",
|
|
@@ -71164,14 +71148,14 @@ var init_c317 = __esm({
|
|
|
71164
71148
|
});
|
|
71165
71149
|
|
|
71166
71150
|
// templates/scheduled/c3.ts
|
|
71167
|
-
var
|
|
71168
|
-
__export(
|
|
71169
|
-
default: () =>
|
|
71151
|
+
var c3_exports17 = {};
|
|
71152
|
+
__export(c3_exports17, {
|
|
71153
|
+
default: () => c3_default17
|
|
71170
71154
|
});
|
|
71171
|
-
var
|
|
71172
|
-
var
|
|
71155
|
+
var c3_default17;
|
|
71156
|
+
var init_c317 = __esm({
|
|
71173
71157
|
"templates/scheduled/c3.ts"() {
|
|
71174
|
-
|
|
71158
|
+
c3_default17 = {
|
|
71175
71159
|
configVersion: 1,
|
|
71176
71160
|
id: "scheduled",
|
|
71177
71161
|
displayName: "Scheduled Worker (Cron Trigger)",
|
|
@@ -71191,14 +71175,14 @@ var init_c318 = __esm({
|
|
|
71191
71175
|
});
|
|
71192
71176
|
|
|
71193
71177
|
// templates/queues/c3.ts
|
|
71194
|
-
var
|
|
71195
|
-
__export(
|
|
71196
|
-
default: () =>
|
|
71178
|
+
var c3_exports18 = {};
|
|
71179
|
+
__export(c3_exports18, {
|
|
71180
|
+
default: () => c3_default18
|
|
71197
71181
|
});
|
|
71198
|
-
var
|
|
71199
|
-
var
|
|
71182
|
+
var c3_default18;
|
|
71183
|
+
var init_c318 = __esm({
|
|
71200
71184
|
"templates/queues/c3.ts"() {
|
|
71201
|
-
|
|
71185
|
+
c3_default18 = {
|
|
71202
71186
|
configVersion: 1,
|
|
71203
71187
|
id: "queues",
|
|
71204
71188
|
displayName: "Queue consumer & producer Worker",
|
|
@@ -71228,17 +71212,17 @@ var init_c319 = __esm({
|
|
|
71228
71212
|
});
|
|
71229
71213
|
|
|
71230
71214
|
// templates/hello-world-durable-object/c3.ts
|
|
71231
|
-
var
|
|
71232
|
-
__export(
|
|
71233
|
-
default: () =>
|
|
71215
|
+
var c3_exports19 = {};
|
|
71216
|
+
__export(c3_exports19, {
|
|
71217
|
+
default: () => c3_default19
|
|
71234
71218
|
});
|
|
71235
|
-
var
|
|
71236
|
-
var
|
|
71219
|
+
var c3_default19;
|
|
71220
|
+
var init_c319 = __esm({
|
|
71237
71221
|
"templates/hello-world-durable-object/c3.ts"() {
|
|
71238
|
-
|
|
71222
|
+
c3_default19 = {
|
|
71239
71223
|
configVersion: 1,
|
|
71240
71224
|
id: "hello-world-durable-object",
|
|
71241
|
-
displayName: "
|
|
71225
|
+
displayName: "Hello World Worker Using Durable Objects",
|
|
71242
71226
|
platform: "workers",
|
|
71243
71227
|
copyFiles: {
|
|
71244
71228
|
variants: {
|
|
@@ -71255,14 +71239,14 @@ var init_c320 = __esm({
|
|
|
71255
71239
|
});
|
|
71256
71240
|
|
|
71257
71241
|
// templates/openapi/c3.ts
|
|
71258
|
-
var
|
|
71259
|
-
__export(
|
|
71260
|
-
default: () =>
|
|
71242
|
+
var c3_exports20 = {};
|
|
71243
|
+
__export(c3_exports20, {
|
|
71244
|
+
default: () => c3_default20
|
|
71261
71245
|
});
|
|
71262
|
-
var
|
|
71263
|
-
var
|
|
71246
|
+
var c3_default20;
|
|
71247
|
+
var init_c320 = __esm({
|
|
71264
71248
|
"templates/openapi/c3.ts"() {
|
|
71265
|
-
|
|
71249
|
+
c3_default20 = {
|
|
71266
71250
|
configVersion: 1,
|
|
71267
71251
|
id: "openapi",
|
|
71268
71252
|
displayName: "API starter (OpenAPI compliant)",
|
|
@@ -71275,10 +71259,10 @@ var init_c321 = __esm({
|
|
|
71275
71259
|
});
|
|
71276
71260
|
|
|
71277
71261
|
// templates/pre-existing/c3.ts
|
|
71278
|
-
var
|
|
71279
|
-
__export(
|
|
71262
|
+
var c3_exports21 = {};
|
|
71263
|
+
__export(c3_exports21, {
|
|
71280
71264
|
copyExistingWorkerFiles: () => copyExistingWorkerFiles,
|
|
71281
|
-
default: () =>
|
|
71265
|
+
default: () => c3_default21
|
|
71282
71266
|
});
|
|
71283
71267
|
async function copyExistingWorkerFiles(ctx) {
|
|
71284
71268
|
const { dlx } = detectPackageManager();
|
|
@@ -71327,8 +71311,8 @@ async function copyExistingWorkerFiles(ctx) {
|
|
|
71327
71311
|
(0, import_path14.join)(ctx.project.path, "wrangler.toml")
|
|
71328
71312
|
);
|
|
71329
71313
|
}
|
|
71330
|
-
var import_promises, import_os, import_path14,
|
|
71331
|
-
var
|
|
71314
|
+
var import_promises, import_os, import_path14, c3_default21;
|
|
71315
|
+
var init_c321 = __esm({
|
|
71332
71316
|
"templates/pre-existing/c3.ts"() {
|
|
71333
71317
|
import_promises = require("fs/promises");
|
|
71334
71318
|
import_os = require("os");
|
|
@@ -71338,7 +71322,7 @@ var init_c322 = __esm({
|
|
|
71338
71322
|
init_command();
|
|
71339
71323
|
init_packageManagers();
|
|
71340
71324
|
init_accounts();
|
|
71341
|
-
|
|
71325
|
+
c3_default21 = {
|
|
71342
71326
|
configVersion: 1,
|
|
71343
71327
|
id: "pre-existing",
|
|
71344
71328
|
displayName: "Pre-existing Worker (from Dashboard)",
|
|
@@ -71381,7 +71365,19 @@ async function copyTemplateFiles(ctx) {
|
|
|
71381
71365
|
}
|
|
71382
71366
|
s.stop(`${brandColor("files")} ${dim("copied to project directory")}`);
|
|
71383
71367
|
}
|
|
71384
|
-
|
|
71368
|
+
function inferLanguageArg(args) {
|
|
71369
|
+
if (args.ts === void 0) {
|
|
71370
|
+
return;
|
|
71371
|
+
}
|
|
71372
|
+
const language = args.ts ? "ts" : "js";
|
|
71373
|
+
if (args.lang !== void 0) {
|
|
71374
|
+
crash(
|
|
71375
|
+
"The `--ts` argument cannot be specified in conjunction with the `--lang` argument"
|
|
71376
|
+
);
|
|
71377
|
+
}
|
|
71378
|
+
args.lang = language;
|
|
71379
|
+
}
|
|
71380
|
+
var import_fs12, import_promises2, import_os2, import_path15, import_deepmerge, import_degit, defaultSelectVariant, getFrameworkMap, getTemplateMap, selectTemplate, selectFramework, selectLanguage, processRemoteTemplate, validateTemplate, validateTemplateSrcDirectory, inferTemplateConfig, inferCopyFilesDefinition, downloadRemoteTemplate, updatePackageName, updatePackageScripts, getTemplatePath, isVariantInfo, getCopyFilesDestinationDir, addWranglerToGitIgnore;
|
|
71385
71381
|
var init_templates = __esm({
|
|
71386
71382
|
"src/templates.ts"() {
|
|
71387
71383
|
import_fs12 = require("fs");
|
|
@@ -71398,8 +71394,7 @@ var init_templates = __esm({
|
|
|
71398
71394
|
init_files();
|
|
71399
71395
|
init_validators();
|
|
71400
71396
|
defaultSelectVariant = async (ctx) => {
|
|
71401
|
-
|
|
71402
|
-
return typescript ? "ts" : "js";
|
|
71397
|
+
return await selectLanguage(ctx);
|
|
71403
71398
|
};
|
|
71404
71399
|
getFrameworkMap = async () => ({
|
|
71405
71400
|
analog: (await Promise.resolve().then(() => (init_c3(), c3_exports))).default,
|
|
@@ -71420,48 +71415,88 @@ var init_templates = __esm({
|
|
|
71420
71415
|
getTemplateMap = async () => {
|
|
71421
71416
|
return {
|
|
71422
71417
|
"hello-world": (await Promise.resolve().then(() => (init_c315(), c3_exports15))).default,
|
|
71423
|
-
|
|
71424
|
-
|
|
71425
|
-
|
|
71426
|
-
|
|
71427
|
-
|
|
71428
|
-
|
|
71429
|
-
"hello-world-durable-object": (await Promise.resolve().then(() => (init_c320(), c3_exports20))).default,
|
|
71430
|
-
openapi: (await Promise.resolve().then(() => (init_c321(), c3_exports21))).default,
|
|
71431
|
-
// Dummy record -- actual template config resolved in `processRemoteTemplate`
|
|
71432
|
-
"remote-template": {
|
|
71433
|
-
displayName: "Worker built from a template hosted in a git repository"
|
|
71434
|
-
},
|
|
71435
|
-
"pre-existing": (await Promise.resolve().then(() => (init_c322(), c3_exports22))).default
|
|
71418
|
+
common: (await Promise.resolve().then(() => (init_c316(), c3_exports16))).default,
|
|
71419
|
+
scheduled: (await Promise.resolve().then(() => (init_c317(), c3_exports17))).default,
|
|
71420
|
+
queues: (await Promise.resolve().then(() => (init_c318(), c3_exports18))).default,
|
|
71421
|
+
"hello-world-durable-object": (await Promise.resolve().then(() => (init_c319(), c3_exports19))).default,
|
|
71422
|
+
openapi: (await Promise.resolve().then(() => (init_c320(), c3_exports20))).default,
|
|
71423
|
+
"pre-existing": (await Promise.resolve().then(() => (init_c321(), c3_exports21))).default
|
|
71436
71424
|
};
|
|
71437
71425
|
};
|
|
71438
71426
|
selectTemplate = async (args) => {
|
|
71439
|
-
if (
|
|
71440
|
-
|
|
71427
|
+
if (args.framework) {
|
|
71428
|
+
args.type ??= "web-framework";
|
|
71429
|
+
} else if (args.template) {
|
|
71430
|
+
args.type ??= "remote-template";
|
|
71431
|
+
} else if (args.existingScript) {
|
|
71432
|
+
args.type ??= "pre-existing";
|
|
71433
|
+
}
|
|
71434
|
+
switch (args.type) {
|
|
71435
|
+
case "hello-world":
|
|
71436
|
+
case "hello-world-durable-object":
|
|
71437
|
+
args.category ??= "hello-world";
|
|
71438
|
+
break;
|
|
71439
|
+
case "hello-world-python":
|
|
71440
|
+
args.category ??= "hello-world";
|
|
71441
|
+
args.type = "hello-world";
|
|
71442
|
+
args.lang = "python";
|
|
71443
|
+
break;
|
|
71444
|
+
case "webFramework":
|
|
71445
|
+
warn(
|
|
71446
|
+
"The `webFramework` type is deprecated and will be removed in a future version. Please use `web-framework` instead."
|
|
71447
|
+
);
|
|
71448
|
+
args.category ??= "web-framework";
|
|
71441
71449
|
args.type = "web-framework";
|
|
71442
|
-
|
|
71443
|
-
|
|
71444
|
-
|
|
71445
|
-
args.
|
|
71446
|
-
|
|
71450
|
+
break;
|
|
71451
|
+
case "web-framework":
|
|
71452
|
+
case "remote-template":
|
|
71453
|
+
args.category ??= args.type;
|
|
71454
|
+
break;
|
|
71455
|
+
case "common":
|
|
71456
|
+
case "scheduled":
|
|
71457
|
+
case "queues":
|
|
71458
|
+
case "openapi":
|
|
71459
|
+
args.category ??= "demo";
|
|
71460
|
+
break;
|
|
71461
|
+
case "pre-existing":
|
|
71462
|
+
args.category ??= "others";
|
|
71463
|
+
break;
|
|
71447
71464
|
}
|
|
71448
|
-
|
|
71449
|
-
|
|
71450
|
-
|
|
71451
|
-
|
|
71452
|
-
|
|
71465
|
+
const category = await processArgument(args, "category", {
|
|
71466
|
+
type: "select",
|
|
71467
|
+
question: "What would you like to start with?",
|
|
71468
|
+
label: "category",
|
|
71469
|
+
options: [
|
|
71470
|
+
{ label: "Hello World example", value: "hello-world" },
|
|
71471
|
+
{ label: "Framework Starter", value: "web-framework" },
|
|
71472
|
+
{ label: "Demo application", value: "demo" },
|
|
71473
|
+
{ label: "Template from a Github repo", value: "remote-template" },
|
|
71474
|
+
// This is used only if the type is `pre-existing`
|
|
71475
|
+
{ label: "Others", value: "others", hidden: true }
|
|
71476
|
+
],
|
|
71477
|
+
defaultValue: C3_DEFAULTS.category
|
|
71478
|
+
});
|
|
71479
|
+
if (category === "web-framework") {
|
|
71480
|
+
return selectFramework(args);
|
|
71481
|
+
}
|
|
71482
|
+
if (category === "remote-template") {
|
|
71483
|
+
return processRemoteTemplate(args);
|
|
71453
71484
|
}
|
|
71454
71485
|
const templateMap = await getTemplateMap();
|
|
71455
71486
|
const templateOptions = Object.entries(templateMap).map(
|
|
71456
|
-
([value, { displayName, hidden: hidden2 }]) =>
|
|
71457
|
-
value
|
|
71458
|
-
|
|
71459
|
-
|
|
71460
|
-
|
|
71487
|
+
([value, { displayName, hidden: hidden2 }]) => {
|
|
71488
|
+
const isHelloWorldExample = value.startsWith("hello-world");
|
|
71489
|
+
const isCategoryMatched = category === "hello-world" ? isHelloWorldExample : !isHelloWorldExample;
|
|
71490
|
+
return {
|
|
71491
|
+
value,
|
|
71492
|
+
label: displayName,
|
|
71493
|
+
hidden: hidden2 || !isCategoryMatched
|
|
71494
|
+
};
|
|
71495
|
+
}
|
|
71461
71496
|
);
|
|
71462
71497
|
const type = await processArgument(args, "type", {
|
|
71463
71498
|
type: "select",
|
|
71464
|
-
question: "
|
|
71499
|
+
question: "Which template would you like to use?",
|
|
71465
71500
|
label: "type",
|
|
71466
71501
|
options: templateOptions,
|
|
71467
71502
|
defaultValue: C3_DEFAULTS.type
|
|
@@ -71472,12 +71507,6 @@ var init_templates = __esm({
|
|
|
71472
71507
|
if (!Object.keys(templateMap).includes(type)) {
|
|
71473
71508
|
return crash(`Unknown application type provided: ${type}.`);
|
|
71474
71509
|
}
|
|
71475
|
-
if (type === "web-framework") {
|
|
71476
|
-
return selectFramework(args);
|
|
71477
|
-
}
|
|
71478
|
-
if (type === "remote-template") {
|
|
71479
|
-
return processRemoteTemplate(args);
|
|
71480
|
-
}
|
|
71481
71510
|
return templateMap[type];
|
|
71482
71511
|
};
|
|
71483
71512
|
selectFramework = async (args) => {
|
|
@@ -71510,18 +71539,26 @@ var init_templates = __esm({
|
|
|
71510
71539
|
...frameworkMap[framework]
|
|
71511
71540
|
};
|
|
71512
71541
|
};
|
|
71513
|
-
|
|
71542
|
+
selectLanguage = async (ctx) => {
|
|
71514
71543
|
if (usesTypescript(ctx)) {
|
|
71515
|
-
return
|
|
71544
|
+
return "ts";
|
|
71516
71545
|
}
|
|
71517
71546
|
if (ctx.template.generate) {
|
|
71518
|
-
return
|
|
71519
|
-
}
|
|
71520
|
-
|
|
71521
|
-
|
|
71522
|
-
|
|
71523
|
-
label: "
|
|
71524
|
-
|
|
71547
|
+
return "js";
|
|
71548
|
+
}
|
|
71549
|
+
inferLanguageArg(ctx.args);
|
|
71550
|
+
const variants = ctx.template.copyFiles && !isVariantInfo(ctx.template.copyFiles) ? Object.keys(ctx.template.copyFiles.variants) : [];
|
|
71551
|
+
const languageOptions = [
|
|
71552
|
+
{ label: "TypeScript", value: "ts" },
|
|
71553
|
+
{ label: "JavaScript", value: "js" },
|
|
71554
|
+
{ label: "Python (beta)", value: "python" }
|
|
71555
|
+
].filter((option) => variants.includes(option.value));
|
|
71556
|
+
return processArgument(ctx.args, "lang", {
|
|
71557
|
+
type: "select",
|
|
71558
|
+
question: "Which language do you want to use?",
|
|
71559
|
+
label: "lang",
|
|
71560
|
+
options: languageOptions,
|
|
71561
|
+
defaultValue: C3_DEFAULTS.lang
|
|
71525
71562
|
});
|
|
71526
71563
|
};
|
|
71527
71564
|
processRemoteTemplate = async (args) => {
|
|
@@ -71532,9 +71569,14 @@ var init_templates = __esm({
|
|
|
71532
71569
|
validate: (val) => validateTemplateUrl(val || C3_DEFAULTS.template),
|
|
71533
71570
|
defaultValue: C3_DEFAULTS.template
|
|
71534
71571
|
});
|
|
71535
|
-
|
|
71572
|
+
let src = templateUrl;
|
|
71573
|
+
if (src.startsWith("https://github.com/") && src.includes("/tree/main/")) {
|
|
71574
|
+
src = src.replace("https://github.com/", "github:").replace("/tree/main/", "/");
|
|
71575
|
+
}
|
|
71576
|
+
const path4 = await downloadRemoteTemplate(src);
|
|
71536
71577
|
const config14 = inferTemplateConfig(path4);
|
|
71537
71578
|
validateTemplate(path4, config14);
|
|
71579
|
+
updateStatus(`${brandColor("template")} ${dim("cloned and validated")}`);
|
|
71538
71580
|
return {
|
|
71539
71581
|
path: path4,
|
|
71540
71582
|
...config14
|
|
@@ -71585,9 +71627,8 @@ var init_templates = __esm({
|
|
|
71585
71627
|
return copyFiles;
|
|
71586
71628
|
};
|
|
71587
71629
|
downloadRemoteTemplate = async (src) => {
|
|
71588
|
-
const s = spinner();
|
|
71589
71630
|
try {
|
|
71590
|
-
|
|
71631
|
+
updateStatus(`Cloning template from: ${blue(src)}`);
|
|
71591
71632
|
const emitter = (0, import_degit.default)(src, {
|
|
71592
71633
|
cache: false,
|
|
71593
71634
|
verbose: false,
|
|
@@ -71595,10 +71636,9 @@ var init_templates = __esm({
|
|
|
71595
71636
|
});
|
|
71596
71637
|
const tmpDir = await (0, import_promises2.mkdtemp)((0, import_path15.join)((0, import_os2.tmpdir)(), "c3-template"));
|
|
71597
71638
|
await emitter.clone(tmpDir);
|
|
71598
|
-
s.stop(`${brandColor("template")} ${dim("cloned and validated")}`);
|
|
71599
71639
|
return tmpDir;
|
|
71600
71640
|
} catch (error2) {
|
|
71601
|
-
|
|
71641
|
+
updateStatus(`${brandColor("template")} ${dim("failed")}`);
|
|
71602
71642
|
return crash(`Failed to clone remote template: ${src}`);
|
|
71603
71643
|
}
|
|
71604
71644
|
};
|
|
@@ -76919,6 +76959,17 @@ var cliDefinition = {
|
|
|
76919
76959
|
}
|
|
76920
76960
|
],
|
|
76921
76961
|
options: [
|
|
76962
|
+
{
|
|
76963
|
+
name: "category",
|
|
76964
|
+
type: "string",
|
|
76965
|
+
description: `Specifies the kind of templates that should be created`,
|
|
76966
|
+
values: [
|
|
76967
|
+
{ name: "hello-world", description: "Hello World example" },
|
|
76968
|
+
{ name: "web-framework", description: "Framework Starter" },
|
|
76969
|
+
{ name: "demo", description: "Demo application" },
|
|
76970
|
+
{ name: "remote-template", description: "Template from a Github repo" }
|
|
76971
|
+
]
|
|
76972
|
+
},
|
|
76922
76973
|
{
|
|
76923
76974
|
name: "type",
|
|
76924
76975
|
alias: "t",
|
|
@@ -76927,13 +76978,9 @@ var cliDefinition = {
|
|
|
76927
76978
|
description: `
|
|
76928
76979
|
When using a built-in template, specifies the type of application that should be created.
|
|
76929
76980
|
|
|
76930
|
-
Note that "--
|
|
76981
|
+
Note that "--category" and "--template" are mutually exclusive options. If both are provided, "--category" will be used.
|
|
76931
76982
|
`,
|
|
76932
76983
|
values: [
|
|
76933
|
-
{
|
|
76934
|
-
name: "web-framework",
|
|
76935
|
-
description: "A website or web application."
|
|
76936
|
-
},
|
|
76937
76984
|
{
|
|
76938
76985
|
name: "hello-world",
|
|
76939
76986
|
description: "A basic \u201CHello World\u201D Cloudflare Worker."
|
|
@@ -76969,7 +77016,7 @@ var cliDefinition = {
|
|
|
76969
77016
|
alias: "f",
|
|
76970
77017
|
type: "string",
|
|
76971
77018
|
requiresArg: true,
|
|
76972
|
-
description: `The type of framework to use to create a web application (when using this option "--
|
|
77019
|
+
description: `The type of framework to use to create a web application (when using this option "--category" is coerced to "web-framework")
|
|
76973
77020
|
|
|
76974
77021
|
When using the --framework option, C3 will dispatch to the official creation tool used by the framework (ex. "create-remix" is used for Remix).
|
|
76975
77022
|
|
|
@@ -76995,6 +77042,12 @@ var cliDefinition = {
|
|
|
76995
77042
|
{ name: "vue" }
|
|
76996
77043
|
]
|
|
76997
77044
|
},
|
|
77045
|
+
{
|
|
77046
|
+
name: "lang",
|
|
77047
|
+
type: "string",
|
|
77048
|
+
description: `The programming language of the template`,
|
|
77049
|
+
values: [{ name: "ts" }, { name: "js" }, { name: "python" }]
|
|
77050
|
+
},
|
|
76998
77051
|
{
|
|
76999
77052
|
name: "deploy",
|
|
77000
77053
|
type: "boolean",
|
|
@@ -77003,7 +77056,8 @@ var cliDefinition = {
|
|
|
77003
77056
|
{
|
|
77004
77057
|
name: "ts",
|
|
77005
77058
|
type: "boolean",
|
|
77006
|
-
description: "Use TypeScript in your application"
|
|
77059
|
+
description: "Use TypeScript in your application",
|
|
77060
|
+
hidden: true
|
|
77007
77061
|
},
|
|
77008
77062
|
{
|
|
77009
77063
|
name: "git",
|
|
@@ -80060,7 +80114,7 @@ var runCli = async (args) => {
|
|
|
80060
80114
|
};
|
|
80061
80115
|
const originalCWD = process.cwd();
|
|
80062
80116
|
const { name, path: path4 } = setupProjectDirectory(validatedArgs);
|
|
80063
|
-
const template = await selectTemplate(
|
|
80117
|
+
const template = await selectTemplate(validatedArgs);
|
|
80064
80118
|
const ctx = {
|
|
80065
80119
|
project: { name, path: path4 },
|
|
80066
80120
|
args: validatedArgs,
|