create-tina-app 1.3.4 → 1.5.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/README.md +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.js +211 -113
- package/dist/templates.d.ts +3 -1
- package/dist/util/asciiArt.d.ts +2 -0
- package/dist/util/checkPkgManagers.d.ts +1 -1
- package/dist/util/git.d.ts +2 -1
- package/dist/util/install.d.ts +2 -2
- package/dist/util/options.d.ts +9 -0
- package/dist/util/packageManagers.d.ts +7 -0
- package/dist/util/preRunChecks.d.ts +2 -1
- package/dist/util/textstyles.d.ts +11 -0
- package/package.json +4 -3
- package/dist/util/logger.d.ts +0 -20
package/README.md
CHANGED
|
@@ -6,6 +6,6 @@ Create Tina App is a powerful command-line interface (CLI) tool designed to kick
|
|
|
6
6
|
|
|
7
7
|
To get started, you need to first build the code - see [contributing](https://github.com/tinacms/tinacms/blob/main/CONTRIBUTING.md).
|
|
8
8
|
|
|
9
|
-
1. run `pnpm link
|
|
9
|
+
1. run `pnpm link --global`
|
|
10
10
|
1. Test your changes by running `npx create-tina-app`
|
|
11
11
|
1. Run `pnpm unlink` when done to unlink the local build
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The available package managers a user can use.
|
|
3
|
-
* To add a new supported package manager, add the usage command to this list.
|
|
4
|
-
* The `PackageManager` type will be automatically updated as a result.
|
|
5
|
-
*/
|
|
6
|
-
declare const PKG_MANAGERS: readonly ["npm", "yarn", "pnpm", "bun"];
|
|
7
|
-
export type PackageManager = (typeof PKG_MANAGERS)[number];
|
|
8
1
|
export declare function run(): Promise<void>;
|
|
9
|
-
export {};
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
7
10
|
var __export = (target, all) => {
|
|
8
11
|
for (var name2 in all)
|
|
9
12
|
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
@@ -26,6 +29,68 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
29
|
));
|
|
27
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
31
|
|
|
32
|
+
// package.json
|
|
33
|
+
var require_package = __commonJS({
|
|
34
|
+
"package.json"(exports2, module2) {
|
|
35
|
+
module2.exports = {
|
|
36
|
+
name: "create-tina-app",
|
|
37
|
+
version: "1.5.0",
|
|
38
|
+
main: "dist/index.js",
|
|
39
|
+
files: [
|
|
40
|
+
"dist",
|
|
41
|
+
"examples",
|
|
42
|
+
"bin/*"
|
|
43
|
+
],
|
|
44
|
+
bin: "bin/create-tina-app",
|
|
45
|
+
typings: "dist/index.d.ts",
|
|
46
|
+
license: "Apache-2.0",
|
|
47
|
+
buildConfig: {
|
|
48
|
+
entryPoints: [
|
|
49
|
+
{
|
|
50
|
+
name: "src/index.ts",
|
|
51
|
+
target: "node"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
engines: {
|
|
56
|
+
node: ">=18.18.0"
|
|
57
|
+
},
|
|
58
|
+
scripts: {
|
|
59
|
+
types: "pnpm tsc",
|
|
60
|
+
build: "tinacms-scripts build",
|
|
61
|
+
"test-run-bin": "pnpm create-tina-app"
|
|
62
|
+
},
|
|
63
|
+
publishConfig: {
|
|
64
|
+
registry: "https://registry.npmjs.org"
|
|
65
|
+
},
|
|
66
|
+
repository: {
|
|
67
|
+
url: "https://github.com/tinacms/tinacms.git",
|
|
68
|
+
directory: "packages/create-tina-app"
|
|
69
|
+
},
|
|
70
|
+
devDependencies: {
|
|
71
|
+
"@tinacms/scripts": "workspace:*",
|
|
72
|
+
"@types/cross-spawn": "catalog:",
|
|
73
|
+
"@types/fs-extra": "^11.0.4",
|
|
74
|
+
"@types/node": "^22.13.1",
|
|
75
|
+
"@types/prompts": "catalog:",
|
|
76
|
+
"@types/tar": "catalog:",
|
|
77
|
+
typescript: "^5.7.3"
|
|
78
|
+
},
|
|
79
|
+
dependencies: {
|
|
80
|
+
"@tinacms/metrics": "workspace:*",
|
|
81
|
+
chalk: "4.1.2",
|
|
82
|
+
commander: "^12.1.0",
|
|
83
|
+
"cross-spawn": "catalog:",
|
|
84
|
+
"fs-extra": "catalog:",
|
|
85
|
+
ora: "^8.2.0",
|
|
86
|
+
prompts: "catalog:",
|
|
87
|
+
tar: "catalog:",
|
|
88
|
+
"validate-npm-package-name": "catalog:"
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
29
94
|
// src/index.ts
|
|
30
95
|
var index_exports = {};
|
|
31
96
|
__export(index_exports, {
|
|
@@ -33,53 +98,25 @@ __export(index_exports, {
|
|
|
33
98
|
});
|
|
34
99
|
module.exports = __toCommonJS(index_exports);
|
|
35
100
|
var import_metrics = require("@tinacms/metrics");
|
|
36
|
-
var import_commander = require("commander");
|
|
37
101
|
var import_prompts = __toESM(require("prompts"));
|
|
38
|
-
var import_node_path = __toESM(require("path"));
|
|
39
|
-
|
|
40
|
-
// package.json
|
|
41
|
-
var name = "create-tina-app";
|
|
42
|
-
var version = "1.3.4";
|
|
102
|
+
var import_node_path = __toESM(require("node:path"));
|
|
43
103
|
|
|
44
104
|
// src/util/fileUtil.ts
|
|
45
105
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
46
106
|
var import_path = __toESM(require("path"));
|
|
47
107
|
|
|
48
|
-
// src/util/
|
|
108
|
+
// src/util/textstyles.ts
|
|
49
109
|
var import_chalk = __toESM(require("chalk"));
|
|
50
110
|
var TextStyles = {
|
|
51
|
-
|
|
52
|
-
|
|
111
|
+
tinaOrange: import_chalk.default.hex("#EC4816"),
|
|
112
|
+
link: (url) => `\x1B]8;;${url}\x07${import_chalk.default.cyan.underline(url)}\x1B]8;;\x07`,
|
|
113
|
+
cmd: import_chalk.default.bgBlackBright.bold.white,
|
|
53
114
|
info: import_chalk.default.blue,
|
|
54
115
|
success: import_chalk.default.green,
|
|
55
116
|
warn: import_chalk.default.yellow,
|
|
56
117
|
err: import_chalk.default.red,
|
|
57
118
|
bold: import_chalk.default.bold
|
|
58
119
|
};
|
|
59
|
-
var Logger = class {
|
|
60
|
-
log(message) {
|
|
61
|
-
console.info(message);
|
|
62
|
-
}
|
|
63
|
-
debug(message) {
|
|
64
|
-
console.debug(TextStyles.info(`[DEBUG] ${message}`));
|
|
65
|
-
}
|
|
66
|
-
info(message) {
|
|
67
|
-
console.info(TextStyles.info(`[INFO] ${message}`));
|
|
68
|
-
}
|
|
69
|
-
success(message) {
|
|
70
|
-
console.log(TextStyles.success(`[SUCCESS] ${message}`));
|
|
71
|
-
}
|
|
72
|
-
cmd(message) {
|
|
73
|
-
console.log(TextStyles.cmd(message));
|
|
74
|
-
}
|
|
75
|
-
warn(message) {
|
|
76
|
-
console.warn(TextStyles.warn(`[WARNING] ${message}`));
|
|
77
|
-
}
|
|
78
|
-
err(message) {
|
|
79
|
-
console.error(TextStyles.err(`[ERROR] ${message}`));
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var log = new Logger();
|
|
83
120
|
|
|
84
121
|
// src/util/fileUtil.ts
|
|
85
122
|
async function isWriteable(directory) {
|
|
@@ -120,24 +157,22 @@ async function setupProjectDirectory(dir) {
|
|
|
120
157
|
process.chdir(dir);
|
|
121
158
|
const conflicts = folderContainsInstallConflicts(dir);
|
|
122
159
|
if (conflicts.length > 0) {
|
|
123
|
-
|
|
124
|
-
`The directory '${TextStyles.bold(
|
|
125
|
-
|
|
126
|
-
)}' contains files that could conflict. Below is a list of conflicts, please remove them and try again.`
|
|
127
|
-
);
|
|
160
|
+
const errorMessageLines = [
|
|
161
|
+
`The directory '${TextStyles.bold(appName)}' contains files that could conflict. Below is a list of conflicts, please remove them and try again.`
|
|
162
|
+
];
|
|
128
163
|
for (const file of conflicts) {
|
|
129
164
|
try {
|
|
130
165
|
const stats = import_fs_extra.default.lstatSync(import_path.default.join(dir, file));
|
|
131
166
|
if (stats.isDirectory()) {
|
|
132
|
-
|
|
167
|
+
errorMessageLines.push(` - ${TextStyles.info(file)}/`);
|
|
133
168
|
} else {
|
|
134
|
-
|
|
169
|
+
errorMessageLines.push(` - ${file}`);
|
|
135
170
|
}
|
|
136
171
|
} catch {
|
|
137
|
-
|
|
172
|
+
errorMessageLines.push(` - ${file}`);
|
|
138
173
|
}
|
|
139
174
|
}
|
|
140
|
-
|
|
175
|
+
throw new Error(errorMessageLines.join("\n"));
|
|
141
176
|
}
|
|
142
177
|
return appName;
|
|
143
178
|
}
|
|
@@ -156,10 +191,10 @@ function updateProjectPackageVersion(dir, version2) {
|
|
|
156
191
|
|
|
157
192
|
// src/util/install.ts
|
|
158
193
|
var import_cross_spawn = __toESM(require("cross-spawn"));
|
|
159
|
-
function install(packageManager) {
|
|
194
|
+
function install(packageManager, verboseOutput) {
|
|
160
195
|
return new Promise((resolve, reject) => {
|
|
161
196
|
const child = (0, import_cross_spawn.default)(packageManager, ["install"], {
|
|
162
|
-
stdio: "inherit",
|
|
197
|
+
stdio: verboseOutput ? "inherit" : "ignore",
|
|
163
198
|
env: { ...process.env, ADBLOCK: "1", DISABLE_OPENCOLLECTIVE: "1" }
|
|
164
199
|
});
|
|
165
200
|
child.on("close", (code) => {
|
|
@@ -204,14 +239,16 @@ function makeFirstCommit(root) {
|
|
|
204
239
|
throw err;
|
|
205
240
|
}
|
|
206
241
|
}
|
|
207
|
-
function initializeGit() {
|
|
242
|
+
function initializeGit(spinner) {
|
|
208
243
|
(0, import_child_process.execSync)("git --version", { stdio: "ignore" });
|
|
209
244
|
if (isInGitRepository() || isInMercurialRepository()) {
|
|
210
|
-
|
|
245
|
+
spinner.warn("Already in a Git repository, skipping.");
|
|
211
246
|
return false;
|
|
212
247
|
}
|
|
213
248
|
if (!import_fs_extra2.default.existsSync(".gitignore")) {
|
|
214
|
-
|
|
249
|
+
spinner.warn(
|
|
250
|
+
"There is no .gitignore file in this repository, creating one..."
|
|
251
|
+
);
|
|
215
252
|
import_fs_extra2.default.writeFileSync(
|
|
216
253
|
".gitignore",
|
|
217
254
|
`node_modules
|
|
@@ -227,8 +264,8 @@ function initializeGit() {
|
|
|
227
264
|
}
|
|
228
265
|
|
|
229
266
|
// src/util/examples.ts
|
|
230
|
-
var import_node_stream = require("stream");
|
|
231
|
-
var import_promises = require("stream/promises");
|
|
267
|
+
var import_node_stream = require("node:stream");
|
|
268
|
+
var import_promises = require("node:stream/promises");
|
|
232
269
|
var import_tar = require("tar");
|
|
233
270
|
async function getRepoInfo(url, examplePath) {
|
|
234
271
|
const [, username, name2, t, _branch, ...file] = url.pathname.split("/");
|
|
@@ -290,56 +327,60 @@ var TEMPLATES = [
|
|
|
290
327
|
description: "Kickstart your project with NextJS \u2013 our top recommendation for a seamless, performant, and versatile web experience.",
|
|
291
328
|
value: "tina-cloud-starter",
|
|
292
329
|
isInternal: false,
|
|
293
|
-
gitURL: "https://github.com/tinacms/tina-cloud-starter"
|
|
330
|
+
gitURL: "https://github.com/tinacms/tina-cloud-starter",
|
|
331
|
+
devUrl: "http://localhost:3000"
|
|
294
332
|
},
|
|
295
333
|
{
|
|
296
334
|
title: "Astro Starter",
|
|
297
335
|
description: "Get started with Astro - a modern static site generator designed for fast, lightweight, and flexible web projects.",
|
|
298
336
|
value: "tina-astro-starter",
|
|
299
337
|
isInternal: false,
|
|
300
|
-
gitURL: "https://github.com/tinacms/tina-astro-starter"
|
|
338
|
+
gitURL: "https://github.com/tinacms/tina-astro-starter",
|
|
339
|
+
devUrl: "http://localhost:4321"
|
|
301
340
|
},
|
|
302
341
|
{
|
|
303
342
|
title: "Hugo Starter",
|
|
304
343
|
description: "With Hugo, you wield the power of lightning-fast site generation, crafting web experiences at the speed of thought.",
|
|
305
344
|
value: "tina-hugo-starter",
|
|
306
345
|
isInternal: false,
|
|
307
|
-
gitURL: "https://github.com/tinacms/tina-hugo-starter"
|
|
346
|
+
gitURL: "https://github.com/tinacms/tina-hugo-starter",
|
|
347
|
+
devUrl: "http://localhost:1313"
|
|
308
348
|
},
|
|
309
349
|
{
|
|
310
350
|
title: "Remix Starter",
|
|
311
351
|
description: "Dive into Remix to orchestrate seamless, interactive user journeys like a maestro of the web.",
|
|
312
352
|
value: "tina-remix-starter",
|
|
313
353
|
isInternal: false,
|
|
314
|
-
gitURL: "https://github.com/tinacms/tina-remix-starter"
|
|
354
|
+
gitURL: "https://github.com/tinacms/tina-remix-starter",
|
|
355
|
+
devUrl: "http://localhost:3000"
|
|
315
356
|
},
|
|
316
357
|
{
|
|
317
358
|
title: "Docusaurus Starter",
|
|
318
359
|
description: "Docusaurus empowers you to build and evolve documentation like crafting a living, breathing knowledge repository.",
|
|
319
360
|
value: "tinasaurus",
|
|
320
361
|
isInternal: false,
|
|
321
|
-
gitURL: "https://github.com/tinacms/tinasaurus"
|
|
362
|
+
gitURL: "https://github.com/tinacms/tinasaurus",
|
|
363
|
+
devUrl: "http://localhost:3000"
|
|
322
364
|
},
|
|
323
365
|
{
|
|
324
366
|
title: "Bare bones starter",
|
|
325
367
|
description: "Stripped down to essentials, this starter is the canvas for pure, unadulterated code creativity.",
|
|
326
368
|
value: "basic",
|
|
327
369
|
isInternal: false,
|
|
328
|
-
gitURL: "https://github.com/tinacms/tina-barebones-starter"
|
|
370
|
+
gitURL: "https://github.com/tinacms/tina-barebones-starter",
|
|
371
|
+
devUrl: "http://localhost:3000"
|
|
329
372
|
}
|
|
330
373
|
];
|
|
331
|
-
async function downloadTemplate(template, root) {
|
|
374
|
+
async function downloadTemplate(template, root, spinner) {
|
|
332
375
|
if (template.isInternal === false) {
|
|
333
376
|
const repoURL = new URL(template.gitURL);
|
|
334
377
|
const repoInfo = await getRepoInfo(repoURL);
|
|
335
378
|
if (!repoInfo) {
|
|
336
379
|
throw new Error("Repository information not found.");
|
|
337
380
|
}
|
|
338
|
-
|
|
339
|
-
`
|
|
340
|
-
|
|
341
|
-
)}.`
|
|
342
|
-
);
|
|
381
|
+
spinner.text = `Downloading files from repo ${TextStyles.tinaOrange(
|
|
382
|
+
`${repoInfo?.username}/${repoInfo?.name}`
|
|
383
|
+
)}`;
|
|
343
384
|
await downloadAndExtractRepo(root, repoInfo);
|
|
344
385
|
} else {
|
|
345
386
|
const templateFile = import_path3.default.join(__dirname, "..", "examples", template.value);
|
|
@@ -348,21 +389,21 @@ async function downloadTemplate(template, root) {
|
|
|
348
389
|
}
|
|
349
390
|
|
|
350
391
|
// src/util/preRunChecks.ts
|
|
351
|
-
var SUPPORTED_NODE_VERSION_BOUNDS = { oldest:
|
|
392
|
+
var SUPPORTED_NODE_VERSION_BOUNDS = { oldest: 20, latest: 22 };
|
|
352
393
|
var SUPPORTED_NODE_VERSION_RANGE = [
|
|
353
394
|
...Array(SUPPORTED_NODE_VERSION_BOUNDS.latest).keys()
|
|
354
395
|
].map((i) => i + SUPPORTED_NODE_VERSION_BOUNDS.oldest);
|
|
355
396
|
var isSupported = SUPPORTED_NODE_VERSION_RANGE.some(
|
|
356
397
|
(version2) => process.version.startsWith(`v${version2}`)
|
|
357
398
|
);
|
|
358
|
-
function preRunChecks() {
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
function checkSupportedNodeVersion() {
|
|
399
|
+
function preRunChecks(spinner) {
|
|
400
|
+
spinner.start("Running pre-run checks...");
|
|
362
401
|
if (!isSupported) {
|
|
363
|
-
|
|
402
|
+
spinner.warn(
|
|
364
403
|
`Node ${process.version} is not supported by create-tina-app. Please update to be within v${SUPPORTED_NODE_VERSION_BOUNDS.oldest}-v${SUPPORTED_NODE_VERSION_BOUNDS.latest}. See https://nodejs.org/en/download/ for more details.`
|
|
365
404
|
);
|
|
405
|
+
} else {
|
|
406
|
+
spinner.succeed(`Node ${process.version} is supported.`);
|
|
366
407
|
}
|
|
367
408
|
}
|
|
368
409
|
|
|
@@ -385,14 +426,21 @@ async function checkPackageExists(name2) {
|
|
|
385
426
|
}
|
|
386
427
|
|
|
387
428
|
// src/index.ts
|
|
388
|
-
var import_node_process = require("process");
|
|
389
|
-
var
|
|
429
|
+
var import_node_process = require("node:process");
|
|
430
|
+
var import_ora = __toESM(require("ora"));
|
|
431
|
+
|
|
432
|
+
// src/util/options.ts
|
|
433
|
+
var import_commander = require("commander");
|
|
434
|
+
var import_package = __toESM(require_package());
|
|
435
|
+
|
|
436
|
+
// src/util/packageManagers.ts
|
|
390
437
|
var PKG_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
|
|
391
|
-
|
|
392
|
-
|
|
438
|
+
|
|
439
|
+
// src/util/options.ts
|
|
440
|
+
function extractOptions(args) {
|
|
393
441
|
let projectName = "";
|
|
394
|
-
const program = new import_commander.Command(name);
|
|
395
|
-
program.version(version).option(
|
|
442
|
+
const program = new import_commander.Command(import_package.name);
|
|
443
|
+
program.version(import_package.version).option(
|
|
396
444
|
"-t, --template <template>",
|
|
397
445
|
`Choose which template to start from. Valid templates are: ${TEMPLATES.map(
|
|
398
446
|
(x2) => x2.value
|
|
@@ -403,20 +451,46 @@ async function run() {
|
|
|
403
451
|
).option(
|
|
404
452
|
"-d, --dir <dir>",
|
|
405
453
|
"Choose which directory to run this script from."
|
|
406
|
-
).option("--noTelemetry", "Disable anonymous telemetry that is collected.").arguments("[project-directory]").usage(`${TextStyles.success("<project-directory>")} [options]`).action((name2) => {
|
|
454
|
+
).option("-v, --verbose", "Enable verbose output.").option("--noTelemetry", "Disable anonymous telemetry that is collected.").arguments("[project-directory]").usage(`${TextStyles.success("<project-directory>")} [options]`).action((name2) => {
|
|
407
455
|
projectName = name2;
|
|
408
456
|
});
|
|
409
|
-
program.parse(
|
|
457
|
+
program.parse(args);
|
|
410
458
|
const opts = program.opts();
|
|
411
459
|
if (opts.dir) {
|
|
412
460
|
process.chdir(opts.dir);
|
|
413
461
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
462
|
+
if (projectName) {
|
|
463
|
+
opts.projectName = projectName;
|
|
464
|
+
}
|
|
465
|
+
return opts;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// src/index.ts
|
|
469
|
+
var import_validate_npm_package_name = __toESM(require("validate-npm-package-name"));
|
|
470
|
+
|
|
471
|
+
// src/util/asciiArt.ts
|
|
472
|
+
var llama = " :--=: \n :-===- \n -=====- \n -=======. \n .=========-. \n :===========--:\n -=============.\n .==========-:. \n :=========-. \n -=========- \n .==========- \n -==========- \n :===========- \n -=============. \n :==============: \n :===============- \n .:-================- \n ..::---==================== \n ....::::::::::-------============================. \n .---=================================================: \n .-=====================================================- \n:=======================================================. \n .-====================================================. \n .-=================================================. \n :=============================================- \n -============================================. \n .============-:. -==========- \n :=========-: .. -==========. \n -========: :-=- -=========- \n .========. .-==== :=========: \n -=======: :=====. -========: \n -======- -====- -=======: \n -=====: -====: :======. \n .=====. -====. .-====- \n :==== -===- -====: \n -==- :===- :====. ";
|
|
473
|
+
var tinaCms = "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\n\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\n \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\n \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\n \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\n \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D";
|
|
474
|
+
|
|
475
|
+
// src/index.ts
|
|
476
|
+
async function run() {
|
|
477
|
+
if (process.stdout.columns >= 60) {
|
|
478
|
+
console.log(TextStyles.tinaOrange(`${llama}`));
|
|
479
|
+
console.log(TextStyles.tinaOrange(`${tinaCms}`));
|
|
480
|
+
} else {
|
|
481
|
+
console.log(TextStyles.tinaOrange(`\u{1F999} TinaCMS`));
|
|
482
|
+
}
|
|
483
|
+
const version2 = require_package().version;
|
|
484
|
+
console.log(`Create Tina App v${version2}`);
|
|
485
|
+
const spinner = (0, import_ora.default)();
|
|
486
|
+
preRunChecks(spinner);
|
|
487
|
+
const opts = extractOptions(process.argv);
|
|
488
|
+
const telemetry = new import_metrics.Telemetry({ disabled: opts?.noTelemetry });
|
|
489
|
+
let template = null;
|
|
490
|
+
if (opts.template) {
|
|
491
|
+
template = TEMPLATES.find((_template) => _template.value === opts.template);
|
|
418
492
|
if (!template) {
|
|
419
|
-
|
|
493
|
+
spinner.fail(
|
|
420
494
|
`The provided template '${opts.template}' is invalid. Please provide one of the following: ${TEMPLATES.map(
|
|
421
495
|
(x2) => x2.value
|
|
422
496
|
)}`
|
|
@@ -427,7 +501,7 @@ async function run() {
|
|
|
427
501
|
let pkgManager = opts.pkgManager;
|
|
428
502
|
if (pkgManager) {
|
|
429
503
|
if (!PKG_MANAGERS.find((_pkgManager) => _pkgManager === pkgManager)) {
|
|
430
|
-
|
|
504
|
+
spinner.fail(
|
|
431
505
|
`The provided package manager '${opts.pkgManager}' is not supported. Please provide one of the following: ${PKG_MANAGERS}`
|
|
432
506
|
);
|
|
433
507
|
(0, import_node_process.exit)(1);
|
|
@@ -441,7 +515,7 @@ async function run() {
|
|
|
441
515
|
}
|
|
442
516
|
}
|
|
443
517
|
if (installedPkgManagers.length === 0) {
|
|
444
|
-
|
|
518
|
+
spinner.fail(
|
|
445
519
|
`You have no supported package managers installed. Please install one of the following: ${PKG_MANAGERS}`
|
|
446
520
|
);
|
|
447
521
|
(0, import_node_process.exit)(1);
|
|
@@ -457,6 +531,7 @@ async function run() {
|
|
|
457
531
|
if (!Object.hasOwn(res, "packageManager")) (0, import_node_process.exit)(1);
|
|
458
532
|
pkgManager = res.packageManager;
|
|
459
533
|
}
|
|
534
|
+
let projectName = opts.projectName;
|
|
460
535
|
if (!projectName) {
|
|
461
536
|
const res = await (0, import_prompts.default)({
|
|
462
537
|
name: "name",
|
|
@@ -487,58 +562,81 @@ async function run() {
|
|
|
487
562
|
await telemetry.submitRecord({
|
|
488
563
|
event: {
|
|
489
564
|
name: "create-tina-app:invoke",
|
|
490
|
-
template,
|
|
565
|
+
template: template.value,
|
|
491
566
|
pkgManager
|
|
492
567
|
}
|
|
493
568
|
});
|
|
494
569
|
const rootDir = import_node_path.default.join(process.cwd(), projectName);
|
|
495
570
|
if (!await isWriteable(import_node_path.default.dirname(rootDir))) {
|
|
496
|
-
|
|
571
|
+
spinner.fail(
|
|
497
572
|
"The application path is not writable, please check folder permissions and try again. It is likely you do not have write permissions for this folder."
|
|
498
573
|
);
|
|
499
574
|
process.exit(1);
|
|
500
575
|
}
|
|
501
|
-
|
|
576
|
+
let appName;
|
|
502
577
|
try {
|
|
503
|
-
await
|
|
578
|
+
appName = await setupProjectDirectory(rootDir);
|
|
579
|
+
} catch (err) {
|
|
580
|
+
spinner.fail(err.message);
|
|
581
|
+
(0, import_node_process.exit)(1);
|
|
582
|
+
}
|
|
583
|
+
try {
|
|
584
|
+
spinner.start("Downloading template...");
|
|
585
|
+
await downloadTemplate(template, rootDir, spinner);
|
|
586
|
+
spinner.succeed();
|
|
587
|
+
spinner.start("Updating project metadata...");
|
|
504
588
|
updateProjectPackageName(rootDir, projectName);
|
|
505
589
|
updateProjectPackageVersion(rootDir, "0.0.1");
|
|
590
|
+
spinner.succeed();
|
|
506
591
|
} catch (err) {
|
|
507
|
-
|
|
592
|
+
spinner.fail(`Failed to download template: ${err.message}`);
|
|
508
593
|
(0, import_node_process.exit)(1);
|
|
509
594
|
}
|
|
510
|
-
|
|
511
|
-
await install(pkgManager);
|
|
512
|
-
log.info("Initializing git repository.");
|
|
595
|
+
spinner.start("Installing packages.");
|
|
513
596
|
try {
|
|
514
|
-
|
|
597
|
+
await install(pkgManager, opts.verbose);
|
|
598
|
+
spinner.succeed();
|
|
599
|
+
} catch (err) {
|
|
600
|
+
spinner.fail(`Failed to install packages: ${err.message}`);
|
|
601
|
+
(0, import_node_process.exit)(1);
|
|
602
|
+
}
|
|
603
|
+
spinner.start("Initializing git repository.");
|
|
604
|
+
try {
|
|
605
|
+
if (initializeGit(spinner)) {
|
|
515
606
|
makeFirstCommit(rootDir);
|
|
516
|
-
|
|
607
|
+
spinner.succeed();
|
|
517
608
|
}
|
|
518
609
|
} catch (err) {
|
|
519
|
-
|
|
610
|
+
spinner.fail("Failed to initialize Git repository, skipping.");
|
|
520
611
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
612
|
+
spinner.succeed(`Created ${TextStyles.tinaOrange(appName)}
|
|
613
|
+
`);
|
|
614
|
+
if (template.value === "tina-hugo-starter") {
|
|
615
|
+
spinner.warn(
|
|
616
|
+
`Hugo is required for this starter. Install it via ${TextStyles.link("https://gohugo.io/installation/")}
|
|
617
|
+
`
|
|
525
618
|
);
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
"https://tina.io/docs/
|
|
537
|
-
)
|
|
538
|
-
|
|
539
|
-
"https://tina.io/docs/
|
|
540
|
-
)
|
|
541
|
-
|
|
619
|
+
}
|
|
620
|
+
const padCommand = (cmd, width = 20) => TextStyles.cmd(cmd) + " ".repeat(Math.max(0, width - cmd.length));
|
|
621
|
+
spinner.info(`${TextStyles.bold("To get started:")}
|
|
622
|
+
|
|
623
|
+
${padCommand(`cd ${appName}`)}# move into your project directory
|
|
624
|
+
${padCommand(`${pkgManager} run dev`)}# start the dev server ${TextStyles.link(template.devUrl)}
|
|
625
|
+
${padCommand(`${pkgManager} run build`)}# build the app for production
|
|
626
|
+
`);
|
|
627
|
+
console.log("Next steps:");
|
|
628
|
+
console.log(
|
|
629
|
+
` \u2022 \u{1F4DD} Edit some content: ${TextStyles.link("https://tina.io/docs/using-tina-editor")}`
|
|
630
|
+
);
|
|
631
|
+
console.log(
|
|
632
|
+
` \u2022 \u{1F4D6} Learn the basics: ${TextStyles.link("https://tina.io/docs/schema/")}`
|
|
633
|
+
);
|
|
634
|
+
console.log(
|
|
635
|
+
` \u2022 \u{1F58C}\uFE0F Extend Tina with custom field components: ${TextStyles.link("https://tina.io/docs/advanced/extending-tina/")}`
|
|
636
|
+
);
|
|
637
|
+
console.log(
|
|
638
|
+
` \u2022 \u{1F680} Deploy to Production: ${TextStyles.link("https://tina.io/docs/tina-cloud/")}`
|
|
639
|
+
);
|
|
542
640
|
}
|
|
543
641
|
run();
|
|
544
642
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/templates.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Ora } from 'ora';
|
|
1
2
|
type BaseExample = {
|
|
2
3
|
title: string;
|
|
3
4
|
description?: string;
|
|
4
5
|
value: string;
|
|
6
|
+
devUrl: string;
|
|
5
7
|
};
|
|
6
8
|
export type InternalTemplate = BaseExample & {
|
|
7
9
|
isInternal: true;
|
|
@@ -12,5 +14,5 @@ export type ExternalTemplate = BaseExample & {
|
|
|
12
14
|
};
|
|
13
15
|
export type Template = InternalTemplate | ExternalTemplate;
|
|
14
16
|
export declare const TEMPLATES: Template[];
|
|
15
|
-
export declare function downloadTemplate(template: Template, root: string): Promise<void>;
|
|
17
|
+
export declare function downloadTemplate(template: Template, root: string, spinner: Ora): Promise<void>;
|
|
16
18
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PackageManager } from '
|
|
1
|
+
import { PackageManager } from './packageManagers';
|
|
2
2
|
export declare function checkPackageExists(name: PackageManager): Promise<boolean>;
|
package/dist/util/git.d.ts
CHANGED
package/dist/util/install.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PackageManager } from '
|
|
1
|
+
import { PackageManager } from './packageManagers';
|
|
2
2
|
/**
|
|
3
3
|
* Spawn a package manager installation.
|
|
4
4
|
*
|
|
5
5
|
* @returns A Promise that resolves once the installation is finished.
|
|
6
6
|
*/
|
|
7
|
-
export declare function install(packageManager: PackageManager): Promise<void>;
|
|
7
|
+
export declare function install(packageManager: PackageManager, verboseOutput: boolean): Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The available package managers a user can use.
|
|
3
|
+
* To add a new supported package manager, add the usage command to this list.
|
|
4
|
+
* The `PackageManager` type will be automatically updated as a result.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PKG_MANAGERS: readonly ["npm", "yarn", "pnpm", "bun"];
|
|
7
|
+
export type PackageManager = (typeof PKG_MANAGERS)[number];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Ora } from 'ora';
|
|
2
|
+
export declare function preRunChecks(spinner: Ora): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tina-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -35,17 +35,18 @@
|
|
|
35
35
|
"@types/prompts": "^2.4.9",
|
|
36
36
|
"@types/tar": "6.1.13",
|
|
37
37
|
"typescript": "^5.7.3",
|
|
38
|
-
"@tinacms/scripts": "1.
|
|
38
|
+
"@tinacms/scripts": "1.4.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"chalk": "4.1.2",
|
|
42
42
|
"commander": "^12.1.0",
|
|
43
43
|
"cross-spawn": "^7.0.6",
|
|
44
44
|
"fs-extra": "^11.3.0",
|
|
45
|
+
"ora": "^8.2.0",
|
|
45
46
|
"prompts": "^2.4.2",
|
|
46
47
|
"tar": "7.4.0",
|
|
47
48
|
"validate-npm-package-name": "^5.0.1",
|
|
48
|
-
"@tinacms/metrics": "1.0
|
|
49
|
+
"@tinacms/metrics": "1.1.0"
|
|
49
50
|
},
|
|
50
51
|
"scripts": {
|
|
51
52
|
"types": "pnpm tsc",
|
package/dist/util/logger.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
export declare const TextStyles: {
|
|
3
|
-
link: chalk.Chalk;
|
|
4
|
-
cmd: chalk.Chalk;
|
|
5
|
-
info: chalk.Chalk;
|
|
6
|
-
success: chalk.Chalk;
|
|
7
|
-
warn: chalk.Chalk;
|
|
8
|
-
err: chalk.Chalk;
|
|
9
|
-
bold: chalk.Chalk;
|
|
10
|
-
};
|
|
11
|
-
export declare class Logger {
|
|
12
|
-
log(message: string): void;
|
|
13
|
-
debug(message: string): void;
|
|
14
|
-
info(message: string): void;
|
|
15
|
-
success(message: string): void;
|
|
16
|
-
cmd(message: string): void;
|
|
17
|
-
warn(message: string): void;
|
|
18
|
-
err(message: string): void;
|
|
19
|
-
}
|
|
20
|
-
export declare const log: Logger;
|