create-tina-app 1.1.5 → 1.1.6
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.js +37 -25
- package/dist/util/examples.d.ts +1 -4
- package/package.json +13 -10
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ 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.6";
|
|
39
39
|
|
|
40
40
|
// src/util/fileUtil.ts
|
|
41
41
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
@@ -244,38 +244,50 @@ function tryGitInit(root) {
|
|
|
244
244
|
var import_node_process = require("process");
|
|
245
245
|
|
|
246
246
|
// src/util/examples.ts
|
|
247
|
-
var
|
|
248
|
-
var
|
|
249
|
-
var
|
|
250
|
-
var import_tar = __toESM(require("tar"));
|
|
251
|
-
var pipeline = (0, import_util.promisify)(import_stream.Stream.pipeline);
|
|
247
|
+
var import_node_stream = require("stream");
|
|
248
|
+
var import_promises = require("stream/promises");
|
|
249
|
+
var import_tar = require("tar");
|
|
252
250
|
async function getRepoInfo(url, examplePath) {
|
|
253
251
|
const [, username, name2, t, _branch, ...file] = url.pathname.split("/");
|
|
254
252
|
const filePath = examplePath ? examplePath.replace(/^\//, "") : file.join("/");
|
|
255
|
-
if (t === void 0) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
253
|
+
if (t === void 0 || t === "" && _branch === void 0) {
|
|
254
|
+
try {
|
|
255
|
+
const infoResponse = await fetch(
|
|
256
|
+
`https://api.github.com/repos/${username}/${name2}`
|
|
257
|
+
);
|
|
258
|
+
if (infoResponse.status !== 200) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const info = await infoResponse.json();
|
|
262
|
+
return { username, name: name2, branch: info.default_branch, filePath };
|
|
263
|
+
} catch {
|
|
260
264
|
return;
|
|
261
265
|
}
|
|
262
|
-
const info = JSON.parse(infoResponse.body);
|
|
263
|
-
return { username, name: name2, branch: info["default_branch"], filePath };
|
|
264
266
|
}
|
|
265
267
|
const branch = examplePath ? `${_branch}/${file.join("/")}`.replace(new RegExp(`/${filePath}|/$`), "") : _branch;
|
|
266
268
|
if (username && name2 && branch && t === "tree") {
|
|
267
269
|
return { username, name: name2, branch, filePath };
|
|
268
270
|
}
|
|
269
271
|
}
|
|
270
|
-
function
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
async function downloadTarStream(url) {
|
|
273
|
+
const res = await fetch(url);
|
|
274
|
+
if (!res.body) {
|
|
275
|
+
throw new Error(`Failed to download: ${url}`);
|
|
276
|
+
}
|
|
277
|
+
return import_node_stream.Readable.fromWeb(res.body);
|
|
278
|
+
}
|
|
279
|
+
async function downloadAndExtractRepo(root, { username, name: name2, branch, filePath }) {
|
|
280
|
+
await (0, import_promises.pipeline)(
|
|
281
|
+
await downloadTarStream(
|
|
273
282
|
`https://codeload.github.com/${username}/${name2}/tar.gz/${branch}`
|
|
274
283
|
),
|
|
275
|
-
import_tar.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
284
|
+
(0, import_tar.x)({
|
|
285
|
+
cwd: root,
|
|
286
|
+
strip: filePath ? filePath.split("/").length + 1 : 1,
|
|
287
|
+
filter: (p) => p.startsWith(
|
|
288
|
+
`${name2}-${branch.replace(/\//g, "-")}${filePath ? `/${filePath}/` : "/"}`
|
|
289
|
+
)
|
|
290
|
+
})
|
|
279
291
|
);
|
|
280
292
|
}
|
|
281
293
|
|
|
@@ -380,8 +392,8 @@ var run = async () => {
|
|
|
380
392
|
name: "packageManager",
|
|
381
393
|
type: "select",
|
|
382
394
|
choices: [
|
|
383
|
-
{ title: "
|
|
384
|
-
{ title: "
|
|
395
|
+
{ title: "yarn", value: "yarn" },
|
|
396
|
+
{ title: "npm", value: "npm" },
|
|
385
397
|
{ title: "pnpm", value: "pnpm" }
|
|
386
398
|
]
|
|
387
399
|
});
|
|
@@ -410,11 +422,11 @@ var run = async () => {
|
|
|
410
422
|
}
|
|
411
423
|
example = res2.example;
|
|
412
424
|
}
|
|
413
|
-
const chosenExample = EXAMPLES.find((
|
|
425
|
+
const chosenExample = EXAMPLES.find((x2) => x2.value === example);
|
|
414
426
|
if (!chosenExample) {
|
|
415
427
|
console.error(
|
|
416
428
|
`The example provided is not a valid example. Please provide one of the following; ${EXAMPLES.map(
|
|
417
|
-
(
|
|
429
|
+
(x2) => x2.value
|
|
418
430
|
)}`
|
|
419
431
|
);
|
|
420
432
|
}
|
|
@@ -444,7 +456,7 @@ var run = async () => {
|
|
|
444
456
|
if (!chosenExample) {
|
|
445
457
|
console.error(
|
|
446
458
|
`The example provided is not a valid example. Please provide one of the following; ${EXAMPLES.map(
|
|
447
|
-
(
|
|
459
|
+
(x2) => x2.value
|
|
448
460
|
)}`
|
|
449
461
|
);
|
|
450
462
|
throw new Error("Invalid example");
|
package/dist/util/examples.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
1
|
export declare type RepoInfo = {
|
|
5
2
|
username: string;
|
|
6
3
|
name: string;
|
|
@@ -10,6 +7,6 @@ export declare type RepoInfo = {
|
|
|
10
7
|
export declare function isUrlOk(url: string): Promise<boolean>;
|
|
11
8
|
export declare function getRepoInfo(url: URL, examplePath?: string): Promise<RepoInfo | undefined>;
|
|
12
9
|
export declare function hasRepo({ username, name, branch, filePath, }: RepoInfo): Promise<boolean>;
|
|
13
|
-
export declare function
|
|
10
|
+
export declare function existsInRepo(nameOrUrl: string): Promise<boolean>;
|
|
14
11
|
export declare function downloadAndExtractRepo(root: string, { username, name, branch, filePath }: RepoInfo): Promise<void>;
|
|
15
12
|
export declare function downloadAndExtractExample(root: string, name: string): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tina-app",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
}
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.18.0"
|
|
23
|
+
},
|
|
21
24
|
"publishConfig": {
|
|
22
25
|
"registry": "https://registry.npmjs.org"
|
|
23
26
|
},
|
|
@@ -26,20 +29,20 @@
|
|
|
26
29
|
"directory": "packages/create-tina-app"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
|
-
"@types/fs-extra": "^9.0.13",
|
|
30
|
-
"@types/node": "^16.11.7",
|
|
31
|
-
"@types/prompts": "^2.0.14",
|
|
32
|
-
"@types/tar": "4.0.3",
|
|
33
32
|
"@types/cross-spawn": "^6.0.6",
|
|
34
|
-
"
|
|
33
|
+
"@types/fs-extra": "^11.0.4",
|
|
34
|
+
"@types/node": "^20.14.12",
|
|
35
|
+
"@types/prompts": "^2.4.9",
|
|
36
|
+
"@types/tar": "6.1.13",
|
|
37
|
+
"typescript": "^4.6.4",
|
|
35
38
|
"@tinacms/scripts": "1.1.6"
|
|
36
39
|
},
|
|
37
40
|
"dependencies": {
|
|
38
|
-
"chalk": "
|
|
39
|
-
"commander": "^
|
|
41
|
+
"chalk": "4.1.2",
|
|
42
|
+
"commander": "^12.1.0",
|
|
40
43
|
"cross-spawn": "^7.0.3",
|
|
41
|
-
"fs-extra": "^
|
|
42
|
-
"got": "^
|
|
44
|
+
"fs-extra": "^11.2.0",
|
|
45
|
+
"got": "^14.4.2",
|
|
43
46
|
"prompts": "^2.4.2",
|
|
44
47
|
"tar": "7.4.0",
|
|
45
48
|
"@tinacms/metrics": "1.0.5"
|