create-tina-app 1.6.1 → 2.0.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/bin/create-tina-app +1 -1
- package/dist/index.js +107 -189
- package/dist/util/textstyles.d.ts +7 -8
- package/package.json +5 -4
package/bin/create-tina-app
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,127 +1,30 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
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
|
-
};
|
|
10
|
-
var __export = (target, all) => {
|
|
11
|
-
for (var name2 in all)
|
|
12
|
-
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
13
|
-
};
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
-
mod
|
|
29
|
-
));
|
|
30
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
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.6.1",
|
|
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: "catalog:",
|
|
86
|
-
prompts: "catalog:",
|
|
87
|
-
tar: "catalog:",
|
|
88
|
-
"validate-npm-package-name": "catalog:"
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
1
|
// src/index.ts
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
module.exports = __toCommonJS(index_exports);
|
|
100
|
-
var import_metrics = require("@tinacms/metrics");
|
|
101
|
-
var import_prompts = __toESM(require("prompts"));
|
|
102
|
-
var import_node_path = __toESM(require("node:path"));
|
|
2
|
+
import { Telemetry } from "@tinacms/metrics";
|
|
3
|
+
import prompts from "prompts";
|
|
4
|
+
import path4 from "node:path";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
103
6
|
|
|
104
7
|
// src/util/fileUtil.ts
|
|
105
|
-
|
|
106
|
-
|
|
8
|
+
import fs from "fs-extra";
|
|
9
|
+
import path from "path";
|
|
107
10
|
|
|
108
11
|
// src/util/textstyles.ts
|
|
109
|
-
|
|
12
|
+
import chalk from "chalk";
|
|
110
13
|
var TextStyles = {
|
|
111
|
-
tinaOrange:
|
|
112
|
-
link: (url) => `\x1B]8;;${url}\x07${
|
|
113
|
-
cmd:
|
|
114
|
-
info:
|
|
115
|
-
success:
|
|
116
|
-
warn:
|
|
117
|
-
err:
|
|
118
|
-
bold:
|
|
14
|
+
tinaOrange: chalk.hex("#EC4816"),
|
|
15
|
+
link: (url) => `\x1B]8;;${url}\x07${chalk.cyan.underline(url)}\x1B]8;;\x07`,
|
|
16
|
+
cmd: chalk.bgBlackBright.bold.white,
|
|
17
|
+
info: chalk.blue,
|
|
18
|
+
success: chalk.green,
|
|
19
|
+
warn: chalk.yellow,
|
|
20
|
+
err: chalk.red,
|
|
21
|
+
bold: chalk.bold
|
|
119
22
|
};
|
|
120
23
|
|
|
121
24
|
// src/util/fileUtil.ts
|
|
122
25
|
async function isWriteable(directory) {
|
|
123
26
|
try {
|
|
124
|
-
await
|
|
27
|
+
await fs.promises.access(directory, (fs.constants || fs).W_OK);
|
|
125
28
|
return true;
|
|
126
29
|
} catch (err) {
|
|
127
30
|
return false;
|
|
@@ -148,12 +51,12 @@ function folderContainsInstallConflicts(root) {
|
|
|
148
51
|
"yarn-debug.log",
|
|
149
52
|
"yarn-error.log"
|
|
150
53
|
];
|
|
151
|
-
const conflicts =
|
|
54
|
+
const conflicts = fs.readdirSync(root).filter((file) => !validFiles.includes(file)).filter((file) => !/\.iml$/.test(file));
|
|
152
55
|
return conflicts;
|
|
153
56
|
}
|
|
154
57
|
async function setupProjectDirectory(dir) {
|
|
155
|
-
const appName =
|
|
156
|
-
await
|
|
58
|
+
const appName = path.basename(dir);
|
|
59
|
+
await fs.mkdirp(dir);
|
|
157
60
|
process.chdir(dir);
|
|
158
61
|
const conflicts = folderContainsInstallConflicts(dir);
|
|
159
62
|
if (conflicts.length > 0) {
|
|
@@ -162,7 +65,7 @@ async function setupProjectDirectory(dir) {
|
|
|
162
65
|
];
|
|
163
66
|
for (const file of conflicts) {
|
|
164
67
|
try {
|
|
165
|
-
const stats =
|
|
68
|
+
const stats = fs.lstatSync(path.join(dir, file));
|
|
166
69
|
if (stats.isDirectory()) {
|
|
167
70
|
errorMessageLines.push(` - ${TextStyles.info(file)}/`);
|
|
168
71
|
} else {
|
|
@@ -177,36 +80,36 @@ async function setupProjectDirectory(dir) {
|
|
|
177
80
|
return appName;
|
|
178
81
|
}
|
|
179
82
|
function updateProjectPackageName(dir, name2) {
|
|
180
|
-
const packageJsonPath =
|
|
181
|
-
const packageJson = JSON.parse(
|
|
83
|
+
const packageJsonPath = path.join(dir, "package.json");
|
|
84
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
182
85
|
packageJson.name = name2;
|
|
183
|
-
|
|
86
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
184
87
|
}
|
|
185
88
|
function updateProjectPackageVersion(dir, version2) {
|
|
186
|
-
const packageJsonPath =
|
|
187
|
-
const packageJson = JSON.parse(
|
|
89
|
+
const packageJsonPath = path.join(dir, "package.json");
|
|
90
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
188
91
|
packageJson.version = version2;
|
|
189
|
-
|
|
92
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
190
93
|
}
|
|
191
94
|
async function updateThemeSettings(dir, selectedTheme) {
|
|
192
|
-
const settingsDir =
|
|
193
|
-
const configPath =
|
|
194
|
-
await
|
|
95
|
+
const settingsDir = path.join(dir, "content", "settings");
|
|
96
|
+
const configPath = path.join(settingsDir, "config.json");
|
|
97
|
+
await fs.mkdirp(settingsDir);
|
|
195
98
|
let config = {};
|
|
196
99
|
try {
|
|
197
|
-
const existingConfig = await
|
|
100
|
+
const existingConfig = await fs.readFile(configPath, "utf8");
|
|
198
101
|
config = JSON.parse(existingConfig);
|
|
199
102
|
} catch (error) {
|
|
200
103
|
}
|
|
201
104
|
config.selectedTheme = selectedTheme;
|
|
202
|
-
await
|
|
105
|
+
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
203
106
|
}
|
|
204
107
|
|
|
205
108
|
// src/util/install.ts
|
|
206
|
-
|
|
109
|
+
import spawn from "cross-spawn";
|
|
207
110
|
function install(packageManager, verboseOutput) {
|
|
208
111
|
return new Promise((resolve, reject) => {
|
|
209
|
-
const child = (
|
|
112
|
+
const child = spawn(packageManager, ["install"], {
|
|
210
113
|
stdio: verboseOutput ? "inherit" : "ignore",
|
|
211
114
|
env: { ...process.env, ADBLOCK: "1", DISABLE_OPENCOLLECTIVE: "1" }
|
|
212
115
|
});
|
|
@@ -221,12 +124,12 @@ function install(packageManager, verboseOutput) {
|
|
|
221
124
|
}
|
|
222
125
|
|
|
223
126
|
// src/util/git.ts
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
127
|
+
import { execSync } from "child_process";
|
|
128
|
+
import path2 from "path";
|
|
129
|
+
import fs2 from "fs-extra";
|
|
227
130
|
function isInGitRepository() {
|
|
228
131
|
try {
|
|
229
|
-
|
|
132
|
+
execSync("git rev-parse --is-inside-work-tree", { stdio: "ignore" });
|
|
230
133
|
return true;
|
|
231
134
|
} catch (_) {
|
|
232
135
|
}
|
|
@@ -234,7 +137,7 @@ function isInGitRepository() {
|
|
|
234
137
|
}
|
|
235
138
|
function isInMercurialRepository() {
|
|
236
139
|
try {
|
|
237
|
-
|
|
140
|
+
execSync("hg --cwd . root", { stdio: "ignore" });
|
|
238
141
|
return true;
|
|
239
142
|
} catch (_) {
|
|
240
143
|
}
|
|
@@ -242,27 +145,27 @@ function isInMercurialRepository() {
|
|
|
242
145
|
}
|
|
243
146
|
function makeFirstCommit(root) {
|
|
244
147
|
try {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
148
|
+
execSync("git checkout -b main", { stdio: "ignore" });
|
|
149
|
+
execSync("git add -A", { stdio: "ignore" });
|
|
150
|
+
execSync('git commit -m "Initial commit from Create Tina App"', {
|
|
248
151
|
stdio: "ignore"
|
|
249
152
|
});
|
|
250
153
|
} catch (err) {
|
|
251
|
-
|
|
154
|
+
fs2.removeSync(path2.join(root, ".git"));
|
|
252
155
|
throw err;
|
|
253
156
|
}
|
|
254
157
|
}
|
|
255
158
|
function initializeGit(spinner) {
|
|
256
|
-
|
|
159
|
+
execSync("git --version", { stdio: "ignore" });
|
|
257
160
|
if (isInGitRepository() || isInMercurialRepository()) {
|
|
258
161
|
spinner.warn("Already in a Git repository, skipping.");
|
|
259
162
|
return false;
|
|
260
163
|
}
|
|
261
|
-
if (!
|
|
164
|
+
if (!fs2.existsSync(".gitignore")) {
|
|
262
165
|
spinner.warn(
|
|
263
166
|
"There is no .gitignore file in this repository, creating one..."
|
|
264
167
|
);
|
|
265
|
-
|
|
168
|
+
fs2.writeFileSync(
|
|
266
169
|
".gitignore",
|
|
267
170
|
`node_modules
|
|
268
171
|
.yarn/*
|
|
@@ -272,14 +175,14 @@ function initializeGit(spinner) {
|
|
|
272
175
|
`
|
|
273
176
|
);
|
|
274
177
|
}
|
|
275
|
-
|
|
178
|
+
execSync("git init", { stdio: "ignore" });
|
|
276
179
|
return true;
|
|
277
180
|
}
|
|
278
181
|
|
|
279
182
|
// src/util/examples.ts
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
183
|
+
import { Readable } from "node:stream";
|
|
184
|
+
import { pipeline } from "node:stream/promises";
|
|
185
|
+
import { x } from "tar";
|
|
283
186
|
async function getRepoInfo(url, examplePath) {
|
|
284
187
|
const [, username, name2, t, _branch, ...file] = url.pathname.split("/");
|
|
285
188
|
const filePath = examplePath ? examplePath.replace(/^\//, "") : file.join("/");
|
|
@@ -314,14 +217,14 @@ async function downloadTarStream(url) {
|
|
|
314
217
|
if (!res.body) {
|
|
315
218
|
throw new Error(`Failed to download: ${url}`);
|
|
316
219
|
}
|
|
317
|
-
return
|
|
220
|
+
return Readable.fromWeb(res.body);
|
|
318
221
|
}
|
|
319
222
|
async function downloadAndExtractRepo(root, { username, name: name2, branch, filePath }) {
|
|
320
|
-
await
|
|
223
|
+
await pipeline(
|
|
321
224
|
await downloadTarStream(
|
|
322
225
|
`https://codeload.github.com/${username}/${name2}/tar.gz/${branch}`
|
|
323
226
|
),
|
|
324
|
-
|
|
227
|
+
x({
|
|
325
228
|
cwd: root,
|
|
326
229
|
strip: filePath ? filePath.split("/").length + 1 : 1,
|
|
327
230
|
filter: (p) => p.startsWith(
|
|
@@ -332,8 +235,8 @@ async function downloadAndExtractRepo(root, { username, name: name2, branch, fil
|
|
|
332
235
|
}
|
|
333
236
|
|
|
334
237
|
// src/templates.ts
|
|
335
|
-
|
|
336
|
-
|
|
238
|
+
import { copy } from "fs-extra";
|
|
239
|
+
import path3 from "path";
|
|
337
240
|
var TEMPLATES = [
|
|
338
241
|
{
|
|
339
242
|
title: "\u2B50 NextJS starter",
|
|
@@ -404,8 +307,8 @@ async function downloadTemplate(template, root, spinner) {
|
|
|
404
307
|
)}`;
|
|
405
308
|
await downloadAndExtractRepo(root, repoInfo);
|
|
406
309
|
} else {
|
|
407
|
-
const templateFile =
|
|
408
|
-
await
|
|
310
|
+
const templateFile = path3.join(__dirname, "..", "examples", template.value);
|
|
311
|
+
await copy(`${templateFile}/`, "./");
|
|
409
312
|
}
|
|
410
313
|
}
|
|
411
314
|
|
|
@@ -429,11 +332,11 @@ function preRunChecks(spinner) {
|
|
|
429
332
|
}
|
|
430
333
|
|
|
431
334
|
// src/util/checkPkgManagers.ts
|
|
432
|
-
|
|
335
|
+
import { exec } from "child_process";
|
|
433
336
|
async function checkPackageExists(name2) {
|
|
434
337
|
try {
|
|
435
338
|
await new Promise((resolve, reject) => {
|
|
436
|
-
|
|
339
|
+
exec(`${name2} -v`, (error, stdout, stderr) => {
|
|
437
340
|
if (error) {
|
|
438
341
|
reject(stderr);
|
|
439
342
|
}
|
|
@@ -447,11 +350,14 @@ async function checkPackageExists(name2) {
|
|
|
447
350
|
}
|
|
448
351
|
|
|
449
352
|
// src/index.ts
|
|
450
|
-
|
|
353
|
+
import { exit } from "node:process";
|
|
451
354
|
|
|
452
355
|
// src/util/options.ts
|
|
453
|
-
|
|
454
|
-
|
|
356
|
+
import { Command } from "commander";
|
|
357
|
+
|
|
358
|
+
// package.json
|
|
359
|
+
var name = "create-tina-app";
|
|
360
|
+
var version = "2.0.0";
|
|
455
361
|
|
|
456
362
|
// src/util/packageManagers.ts
|
|
457
363
|
var PKG_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
|
|
@@ -459,8 +365,8 @@ var PKG_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
|
|
|
459
365
|
// src/util/options.ts
|
|
460
366
|
function extractOptions(args) {
|
|
461
367
|
let projectName = "";
|
|
462
|
-
const program = new
|
|
463
|
-
program.version(
|
|
368
|
+
const program = new Command(name);
|
|
369
|
+
program.version(version).option(
|
|
464
370
|
"-t, --template <template>",
|
|
465
371
|
`Choose which template to start from. Valid templates are: ${TEMPLATES.map(
|
|
466
372
|
(x2) => x2.value
|
|
@@ -486,7 +392,7 @@ function extractOptions(args) {
|
|
|
486
392
|
}
|
|
487
393
|
|
|
488
394
|
// src/index.ts
|
|
489
|
-
|
|
395
|
+
import validate from "validate-npm-package-name";
|
|
490
396
|
|
|
491
397
|
// src/util/asciiArt.ts
|
|
492
398
|
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 -==- :===- :====. ";
|
|
@@ -536,12 +442,13 @@ async function run() {
|
|
|
536
442
|
} else {
|
|
537
443
|
console.log(TextStyles.tinaOrange(`\u{1F999} TinaCMS`));
|
|
538
444
|
}
|
|
539
|
-
const
|
|
445
|
+
const require2 = createRequire(import.meta.url);
|
|
446
|
+
const version2 = require2("../package.json").version;
|
|
540
447
|
console.log(`Create Tina App v${version2}`);
|
|
541
448
|
const spinner = ora();
|
|
542
449
|
preRunChecks(spinner);
|
|
543
450
|
const opts = extractOptions(process.argv);
|
|
544
|
-
const telemetry = new
|
|
451
|
+
const telemetry = new Telemetry({ disabled: opts?.noTelemetry });
|
|
545
452
|
let template = null;
|
|
546
453
|
if (opts.template) {
|
|
547
454
|
template = TEMPLATES.find((_template) => _template.value === opts.template);
|
|
@@ -551,7 +458,7 @@ async function run() {
|
|
|
551
458
|
(x2) => x2.value
|
|
552
459
|
)}`
|
|
553
460
|
);
|
|
554
|
-
|
|
461
|
+
exit(1);
|
|
555
462
|
}
|
|
556
463
|
}
|
|
557
464
|
let pkgManager = opts.pkgManager;
|
|
@@ -560,7 +467,7 @@ async function run() {
|
|
|
560
467
|
spinner.fail(
|
|
561
468
|
`The provided package manager '${opts.pkgManager}' is not supported. Please provide one of the following: ${PKG_MANAGERS}`
|
|
562
469
|
);
|
|
563
|
-
|
|
470
|
+
exit(1);
|
|
564
471
|
}
|
|
565
472
|
}
|
|
566
473
|
if (!pkgManager) {
|
|
@@ -574,9 +481,9 @@ async function run() {
|
|
|
574
481
|
spinner.fail(
|
|
575
482
|
`You have no supported package managers installed. Please install one of the following: ${PKG_MANAGERS}`
|
|
576
483
|
);
|
|
577
|
-
|
|
484
|
+
exit(1);
|
|
578
485
|
}
|
|
579
|
-
const res = await (
|
|
486
|
+
const res = await prompts({
|
|
580
487
|
message: "Which package manager would you like to use?",
|
|
581
488
|
name: "packageManager",
|
|
582
489
|
type: "select",
|
|
@@ -584,46 +491,46 @@ async function run() {
|
|
|
584
491
|
return { title: manager, value: manager };
|
|
585
492
|
})
|
|
586
493
|
});
|
|
587
|
-
if (!Object.hasOwn(res, "packageManager"))
|
|
494
|
+
if (!Object.hasOwn(res, "packageManager")) exit(1);
|
|
588
495
|
pkgManager = res.packageManager;
|
|
589
496
|
}
|
|
590
497
|
let projectName = opts.projectName;
|
|
591
498
|
if (!projectName) {
|
|
592
|
-
const res = await (
|
|
499
|
+
const res = await prompts({
|
|
593
500
|
name: "name",
|
|
594
501
|
type: "text",
|
|
595
502
|
message: "What is your project named?",
|
|
596
503
|
initial: "my-tina-app",
|
|
597
504
|
validate: (name2) => {
|
|
598
|
-
const { validForNewPackages, errors } = (
|
|
599
|
-
|
|
505
|
+
const { validForNewPackages, errors } = validate(
|
|
506
|
+
path4.basename(path4.resolve(name2))
|
|
600
507
|
);
|
|
601
508
|
if (validForNewPackages) return true;
|
|
602
509
|
return `Invalid project name: ${errors[0]}`;
|
|
603
510
|
}
|
|
604
511
|
});
|
|
605
|
-
if (!Object.hasOwn(res, "name"))
|
|
512
|
+
if (!Object.hasOwn(res, "name")) exit(1);
|
|
606
513
|
projectName = res.name;
|
|
607
514
|
}
|
|
608
515
|
if (!template) {
|
|
609
|
-
const res = await (
|
|
516
|
+
const res = await prompts({
|
|
610
517
|
name: "template",
|
|
611
518
|
type: "select",
|
|
612
519
|
message: "What starter code would you like to use?",
|
|
613
520
|
choices: TEMPLATES
|
|
614
521
|
});
|
|
615
|
-
if (!Object.hasOwn(res, "template"))
|
|
522
|
+
if (!Object.hasOwn(res, "template")) exit(1);
|
|
616
523
|
template = TEMPLATES.find((_template) => _template.value === res.template);
|
|
617
524
|
}
|
|
618
525
|
let themeChoice;
|
|
619
526
|
if (template.value === "tina-docs") {
|
|
620
|
-
const res = await (
|
|
527
|
+
const res = await prompts({
|
|
621
528
|
name: "theme",
|
|
622
529
|
type: "select",
|
|
623
530
|
message: "What theme would you like to use?",
|
|
624
531
|
choices: THEMES
|
|
625
532
|
});
|
|
626
|
-
if (!Object.hasOwn(res, "theme"))
|
|
533
|
+
if (!Object.hasOwn(res, "theme")) exit(1);
|
|
627
534
|
themeChoice = res.theme;
|
|
628
535
|
}
|
|
629
536
|
await telemetry.submitRecord({
|
|
@@ -633,8 +540,8 @@ async function run() {
|
|
|
633
540
|
pkgManager
|
|
634
541
|
}
|
|
635
542
|
});
|
|
636
|
-
const rootDir =
|
|
637
|
-
if (!await isWriteable(
|
|
543
|
+
const rootDir = path4.join(process.cwd(), projectName);
|
|
544
|
+
if (!await isWriteable(path4.dirname(rootDir))) {
|
|
638
545
|
spinner.fail(
|
|
639
546
|
"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."
|
|
640
547
|
);
|
|
@@ -645,7 +552,7 @@ async function run() {
|
|
|
645
552
|
appName = await setupProjectDirectory(rootDir);
|
|
646
553
|
} catch (err) {
|
|
647
554
|
spinner.fail(err.message);
|
|
648
|
-
|
|
555
|
+
exit(1);
|
|
649
556
|
}
|
|
650
557
|
try {
|
|
651
558
|
await downloadTemplate(template, rootDir, spinner);
|
|
@@ -661,7 +568,7 @@ async function run() {
|
|
|
661
568
|
spinner.succeed();
|
|
662
569
|
} catch (err) {
|
|
663
570
|
spinner.fail(`Failed to download template: ${err.message}`);
|
|
664
|
-
|
|
571
|
+
exit(1);
|
|
665
572
|
}
|
|
666
573
|
spinner.start("Installing packages.");
|
|
667
574
|
try {
|
|
@@ -684,7 +591,9 @@ async function run() {
|
|
|
684
591
|
`);
|
|
685
592
|
if (template.value === "tina-hugo-starter") {
|
|
686
593
|
spinner.warn(
|
|
687
|
-
`Hugo is required for this starter. Install it via ${TextStyles.link(
|
|
594
|
+
`Hugo is required for this starter. Install it via ${TextStyles.link(
|
|
595
|
+
"https://gohugo.io/installation/"
|
|
596
|
+
)}
|
|
688
597
|
`
|
|
689
598
|
);
|
|
690
599
|
}
|
|
@@ -693,28 +602,37 @@ async function run() {
|
|
|
693
602
|
|
|
694
603
|
${padCommand(`cd ${appName}`)}# move into your project directory${packageManagerInstallationHadError ? `
|
|
695
604
|
${padCommand(`${pkgManager} install`)}# install dependencies` : ""}
|
|
696
|
-
${padCommand(
|
|
605
|
+
${padCommand(
|
|
606
|
+
`${pkgManager} run dev`
|
|
607
|
+
)}# start the dev server ${TextStyles.link(template.devUrl)}
|
|
697
608
|
${padCommand(`${pkgManager} run build`)}# build the app for production
|
|
698
609
|
`);
|
|
699
610
|
console.log("Next steps:");
|
|
700
611
|
console.log(
|
|
701
|
-
` \u2022 \u{1F4DD} Edit some content: ${TextStyles.link(
|
|
612
|
+
` \u2022 \u{1F4DD} Edit some content: ${TextStyles.link(
|
|
613
|
+
"https://tina.io/docs/using-tina-editor"
|
|
614
|
+
)}`
|
|
702
615
|
);
|
|
703
616
|
console.log(
|
|
704
|
-
` \u2022 \u{1F4D6} Learn the basics: ${TextStyles.link(
|
|
617
|
+
` \u2022 \u{1F4D6} Learn the basics: ${TextStyles.link(
|
|
618
|
+
"https://tina.io/docs/schema/"
|
|
619
|
+
)}`
|
|
705
620
|
);
|
|
706
621
|
console.log(
|
|
707
|
-
` \u2022 \u{1F58C}\uFE0F Extend Tina with custom field components: ${TextStyles.link(
|
|
622
|
+
` \u2022 \u{1F58C}\uFE0F Extend Tina with custom field components: ${TextStyles.link(
|
|
623
|
+
"https://tina.io/docs/advanced/extending-tina/"
|
|
624
|
+
)}`
|
|
708
625
|
);
|
|
709
626
|
console.log(
|
|
710
|
-
` \u2022 \u{1F680} Deploy to Production: ${TextStyles.link(
|
|
627
|
+
` \u2022 \u{1F680} Deploy to Production: ${TextStyles.link(
|
|
628
|
+
"https://tina.io/docs/tinacloud/"
|
|
629
|
+
)}`
|
|
711
630
|
);
|
|
712
631
|
}
|
|
713
632
|
run().catch((error) => {
|
|
714
633
|
console.error("Error running create-tina-app:", error);
|
|
715
634
|
process.exit(1);
|
|
716
635
|
});
|
|
717
|
-
|
|
718
|
-
0 && (module.exports = {
|
|
636
|
+
export {
|
|
719
637
|
run
|
|
720
|
-
}
|
|
638
|
+
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
1
|
export declare const TextStyles: {
|
|
3
|
-
tinaOrange: chalk.
|
|
2
|
+
tinaOrange: import("chalk").ChalkInstance;
|
|
4
3
|
link: (url: string) => string;
|
|
5
|
-
cmd: chalk.
|
|
6
|
-
info: chalk.
|
|
7
|
-
success: chalk.
|
|
8
|
-
warn: chalk.
|
|
9
|
-
err: chalk.
|
|
10
|
-
bold: chalk.
|
|
4
|
+
cmd: import("chalk").ChalkInstance;
|
|
5
|
+
info: import("chalk").ChalkInstance;
|
|
6
|
+
success: import("chalk").ChalkInstance;
|
|
7
|
+
warn: import("chalk").ChalkInstance;
|
|
8
|
+
err: import("chalk").ChalkInstance;
|
|
9
|
+
bold: import("chalk").ChalkInstance;
|
|
11
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tina-app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "dist/index.js",
|
|
5
6
|
"files": [
|
|
6
7
|
"dist",
|
|
@@ -35,10 +36,10 @@
|
|
|
35
36
|
"@types/prompts": "^2.4.9",
|
|
36
37
|
"@types/tar": "6.1.13",
|
|
37
38
|
"typescript": "^5.7.3",
|
|
38
|
-
"@tinacms/scripts": "1.4.
|
|
39
|
+
"@tinacms/scripts": "1.4.2"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"chalk": "4.1
|
|
42
|
+
"chalk": "^5.4.1",
|
|
42
43
|
"commander": "^12.1.0",
|
|
43
44
|
"cross-spawn": "^7.0.6",
|
|
44
45
|
"fs-extra": "^11.3.0",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"prompts": "^2.4.2",
|
|
47
48
|
"tar": "7.4.0",
|
|
48
49
|
"validate-npm-package-name": "^5.0.1",
|
|
49
|
-
"@tinacms/metrics": "
|
|
50
|
+
"@tinacms/metrics": "2.0.1"
|
|
50
51
|
},
|
|
51
52
|
"scripts": {
|
|
52
53
|
"types": "pnpm tsc",
|