create-tina-app 1.1.3 → 1.1.5
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/index.d.ts +0 -3
- package/dist/index.js +72 -43
- package/dist/util/install.d.ts +4 -7
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -31,11 +31,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
31
31
|
var import_metrics = require("@tinacms/metrics");
|
|
32
32
|
var import_commander = require("commander");
|
|
33
33
|
var import_prompts = __toESM(require("prompts"));
|
|
34
|
-
var
|
|
34
|
+
var import_node_path = __toESM(require("path"));
|
|
35
35
|
|
|
36
36
|
// package.json
|
|
37
37
|
var name = "create-tina-app";
|
|
38
|
-
var version = "1.1.
|
|
38
|
+
var version = "1.1.5";
|
|
39
39
|
|
|
40
40
|
// src/util/fileUtil.ts
|
|
41
41
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
@@ -104,46 +104,61 @@ function isFolderEmpty(root, name2) {
|
|
|
104
104
|
// src/util/install.ts
|
|
105
105
|
var import_chalk2 = __toESM(require("chalk"));
|
|
106
106
|
var import_cross_spawn = __toESM(require("cross-spawn"));
|
|
107
|
-
function install(root, dependencies, {
|
|
107
|
+
function install(root, dependencies, { packageManager, isOnline, devDependencies }) {
|
|
108
108
|
const npmFlags = [];
|
|
109
109
|
const yarnFlags = [];
|
|
110
|
+
const pnpmFlags = [];
|
|
110
111
|
return new Promise((resolve, reject) => {
|
|
111
112
|
let args;
|
|
112
|
-
const command =
|
|
113
|
-
if (dependencies
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
113
|
+
const command = packageManager;
|
|
114
|
+
if (dependencies == null ? void 0 : dependencies.length) {
|
|
115
|
+
switch (packageManager) {
|
|
116
|
+
case "yarn":
|
|
117
|
+
args = ["add", "--exact"];
|
|
118
|
+
if (!isOnline)
|
|
119
|
+
args.push("--offline");
|
|
120
|
+
args.push("--cwd", root);
|
|
121
|
+
if (devDependencies)
|
|
122
|
+
args.push("--dev");
|
|
123
|
+
args.push(...dependencies);
|
|
124
|
+
break;
|
|
125
|
+
case "npm":
|
|
126
|
+
args = ["install", "--save-exact"];
|
|
127
|
+
args.push(devDependencies ? "--save-dev" : "--save");
|
|
128
|
+
args.push(...dependencies);
|
|
129
|
+
break;
|
|
130
|
+
case "pnpm":
|
|
131
|
+
args = ["add"];
|
|
132
|
+
if (!isOnline)
|
|
133
|
+
args.push("--offline");
|
|
134
|
+
args.push("--save-exact");
|
|
135
|
+
if (devDependencies)
|
|
136
|
+
args.push("-D");
|
|
137
|
+
args.push(...dependencies);
|
|
138
|
+
break;
|
|
126
139
|
}
|
|
127
140
|
} else {
|
|
128
141
|
args = ["install"];
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
|
|
142
|
+
if (!isOnline) {
|
|
143
|
+
console.log(import_chalk2.default.yellow("You appear to be offline."));
|
|
144
|
+
if (packageManager === "yarn") {
|
|
132
145
|
console.log(import_chalk2.default.yellow("Falling back to the local Yarn cache."));
|
|
133
|
-
console.log();
|
|
134
146
|
args.push("--offline");
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
if (!isOnline) {
|
|
138
|
-
console.log(import_chalk2.default.yellow("You appear to be offline."));
|
|
147
|
+
} else {
|
|
139
148
|
console.log();
|
|
140
149
|
}
|
|
141
150
|
}
|
|
142
151
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
152
|
+
switch (packageManager) {
|
|
153
|
+
case "yarn":
|
|
154
|
+
args.push(...yarnFlags);
|
|
155
|
+
break;
|
|
156
|
+
case "npm":
|
|
157
|
+
args.push(...npmFlags);
|
|
158
|
+
break;
|
|
159
|
+
case "pnpm":
|
|
160
|
+
args.push(...pnpmFlags);
|
|
161
|
+
break;
|
|
147
162
|
}
|
|
148
163
|
const child = (0, import_cross_spawn.default)(command, args, {
|
|
149
164
|
stdio: "inherit",
|
|
@@ -226,7 +241,7 @@ function tryGitInit(root) {
|
|
|
226
241
|
}
|
|
227
242
|
|
|
228
243
|
// src/index.ts
|
|
229
|
-
var
|
|
244
|
+
var import_node_process = require("process");
|
|
230
245
|
|
|
231
246
|
// src/util/examples.ts
|
|
232
247
|
var import_got = __toESM(require("got"));
|
|
@@ -319,9 +334,12 @@ var downloadExample = async (example, root) => {
|
|
|
319
334
|
const repoInfo2 = repoInfo;
|
|
320
335
|
console.log(
|
|
321
336
|
`Downloading files from repo ${import_chalk4.default.cyan(
|
|
322
|
-
repoInfo.username
|
|
337
|
+
`${repoInfo == null ? void 0 : repoInfo.username}/${repoInfo == null ? void 0 : repoInfo.name}`
|
|
323
338
|
)}. This might take a moment.`
|
|
324
339
|
);
|
|
340
|
+
if (!repoInfo2) {
|
|
341
|
+
throw new Error("downloadExample Failed. Repo info not found");
|
|
342
|
+
}
|
|
325
343
|
await downloadAndExtractRepo(root, repoInfo2);
|
|
326
344
|
} else {
|
|
327
345
|
const exampleFile = import_path3.default.join(__dirname, "..", "examples", example.value);
|
|
@@ -359,15 +377,16 @@ var run = async () => {
|
|
|
359
377
|
let example = opts.example;
|
|
360
378
|
const res = await (0, import_prompts.default)({
|
|
361
379
|
message: "Which package manager would you like to use?",
|
|
362
|
-
name: "
|
|
380
|
+
name: "packageManager",
|
|
363
381
|
type: "select",
|
|
364
382
|
choices: [
|
|
365
383
|
{ title: "Yarn", value: "yarn" },
|
|
366
|
-
{ title: "NPM", value: "npm" }
|
|
384
|
+
{ title: "NPM", value: "npm" },
|
|
385
|
+
{ title: "pnpm", value: "pnpm" }
|
|
367
386
|
]
|
|
368
387
|
});
|
|
369
|
-
const
|
|
370
|
-
const displayedCommand =
|
|
388
|
+
const packageManager = res.packageManager;
|
|
389
|
+
const displayedCommand = packageManager;
|
|
371
390
|
if (!projectName) {
|
|
372
391
|
const res2 = await (0, import_prompts.default)({
|
|
373
392
|
name: "name",
|
|
@@ -387,7 +406,7 @@ var run = async () => {
|
|
|
387
406
|
});
|
|
388
407
|
if (typeof res2.example !== "string") {
|
|
389
408
|
console.error(import_chalk5.default.red("Input must be a string"));
|
|
390
|
-
(0,
|
|
409
|
+
(0, import_node_process.exit)(1);
|
|
391
410
|
}
|
|
392
411
|
example = res2.example;
|
|
393
412
|
}
|
|
@@ -403,11 +422,11 @@ var run = async () => {
|
|
|
403
422
|
event: {
|
|
404
423
|
name: "create-tina-app:invoke",
|
|
405
424
|
example,
|
|
406
|
-
useYarn: Boolean(
|
|
425
|
+
useYarn: Boolean(res.packageManager === "yarn")
|
|
407
426
|
}
|
|
408
427
|
});
|
|
409
|
-
const root =
|
|
410
|
-
if (!await isWriteable(
|
|
428
|
+
const root = import_node_path.default.join(process.cwd(), dirName);
|
|
429
|
+
if (!await isWriteable(import_node_path.default.dirname(root))) {
|
|
411
430
|
console.error(
|
|
412
431
|
"The application path is not writable, please check folder permissions and try again."
|
|
413
432
|
);
|
|
@@ -416,27 +435,37 @@ var run = async () => {
|
|
|
416
435
|
);
|
|
417
436
|
process.exit(1);
|
|
418
437
|
}
|
|
419
|
-
const appName =
|
|
438
|
+
const appName = import_node_path.default.basename(root);
|
|
420
439
|
await makeDir(root);
|
|
421
440
|
process.chdir(root);
|
|
422
441
|
if (!isFolderEmpty(root, appName)) {
|
|
423
442
|
process.exit(1);
|
|
424
443
|
}
|
|
444
|
+
if (!chosenExample) {
|
|
445
|
+
console.error(
|
|
446
|
+
`The example provided is not a valid example. Please provide one of the following; ${EXAMPLES.map(
|
|
447
|
+
(x) => x.value
|
|
448
|
+
)}`
|
|
449
|
+
);
|
|
450
|
+
throw new Error("Invalid example");
|
|
451
|
+
}
|
|
425
452
|
await downloadExample(chosenExample, root);
|
|
426
453
|
console.log(
|
|
427
454
|
logText("Installing packages. This might take a couple of minutes.")
|
|
428
455
|
);
|
|
429
456
|
console.log();
|
|
430
|
-
await install(root, null, {
|
|
457
|
+
await install(root, null, { packageManager, isOnline: true });
|
|
431
458
|
if (tryGitInit(root)) {
|
|
432
459
|
console.log(logText("Initializing git repository."));
|
|
433
460
|
console.log();
|
|
434
461
|
}
|
|
435
462
|
console.log(`${successText("Starter successfully created!")}`);
|
|
436
463
|
console.log(import_chalk5.default.bold("\nTo launch your app, run:\n"));
|
|
437
|
-
console.log(
|
|
464
|
+
console.log(` ${cmdText(`cd ${appName}`)}`);
|
|
438
465
|
console.log(
|
|
439
|
-
` ${cmdText(
|
|
466
|
+
` ${cmdText(
|
|
467
|
+
`${displayedCommand} ${packageManager === "npm" ? "run " : ""}dev`
|
|
468
|
+
)}`
|
|
440
469
|
);
|
|
441
470
|
console.log();
|
|
442
471
|
console.log("Next steps:");
|
package/dist/util/install.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
1
|
interface InstallArgs {
|
|
5
2
|
/**
|
|
6
|
-
*
|
|
3
|
+
* The package manager to use (yarn, npm, pnpm).
|
|
7
4
|
*/
|
|
8
|
-
|
|
5
|
+
packageManager: 'yarn' | 'npm' | 'pnpm';
|
|
9
6
|
/**
|
|
10
7
|
* Indicate whether there is an active Internet connection.
|
|
11
8
|
*/
|
|
@@ -16,9 +13,9 @@ interface InstallArgs {
|
|
|
16
13
|
devDependencies?: boolean;
|
|
17
14
|
}
|
|
18
15
|
/**
|
|
19
|
-
* Spawn a package manager installation with
|
|
16
|
+
* Spawn a package manager installation with Yarn, NPM, or PNPM.
|
|
20
17
|
*
|
|
21
18
|
* @returns A Promise that resolves once the installation is finished.
|
|
22
19
|
*/
|
|
23
|
-
export declare function install(root: string, dependencies: string[] | null, {
|
|
20
|
+
export declare function install(root: string, dependencies: string[] | null, { packageManager, isOnline, devDependencies }: InstallArgs): Promise<void>;
|
|
24
21
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tina-app",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"@types/node": "^16.11.7",
|
|
31
31
|
"@types/prompts": "^2.0.14",
|
|
32
32
|
"@types/tar": "4.0.3",
|
|
33
|
+
"@types/cross-spawn": "^6.0.6",
|
|
33
34
|
"typescript": "4.6.4",
|
|
34
|
-
"@tinacms/scripts": "1.1.
|
|
35
|
+
"@tinacms/scripts": "1.1.6"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
38
|
"chalk": "^4.1.2",
|
|
@@ -40,8 +41,8 @@
|
|
|
40
41
|
"fs-extra": "^10.0.0",
|
|
41
42
|
"got": "^11.8.5",
|
|
42
43
|
"prompts": "^2.4.2",
|
|
43
|
-
"tar": "
|
|
44
|
-
"@tinacms/metrics": "1.0.
|
|
44
|
+
"tar": "7.4.0",
|
|
45
|
+
"@tinacms/metrics": "1.0.5"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
48
|
"types": "pnpm tsc",
|