create-creact 0.1.0 → 0.1.1
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/create.js +8 -2
- package/dist/main.js +7 -5
- package/dist/shell.js +19 -8
- package/dist/ui.js +3 -2
- package/package.json +2 -2
package/dist/create.js
CHANGED
|
@@ -243,11 +243,11 @@ async function restoreSkills(dir, log) {
|
|
|
243
243
|
catch (error) {
|
|
244
244
|
if (!(error instanceof CommandFailed))
|
|
245
245
|
throw error;
|
|
246
|
-
const where = log
|
|
246
|
+
const where = outputAt(log);
|
|
247
247
|
return {
|
|
248
248
|
skills: {
|
|
249
249
|
failed: (await succeeds("git", ["--version"], dir))
|
|
250
|
-
? `${error.message}
|
|
250
|
+
? `${error.message}${where}`
|
|
251
251
|
: "git isn't on PATH, and the restore clones the skills with it",
|
|
252
252
|
},
|
|
253
253
|
skillCount,
|
|
@@ -255,3 +255,9 @@ async function restoreSkills(dir, log) {
|
|
|
255
255
|
}
|
|
256
256
|
return { skills: "restored", skillCount };
|
|
257
257
|
}
|
|
258
|
+
// Where the failed command's output can be read, as the end of a sentence.
|
|
259
|
+
function outputAt(log) {
|
|
260
|
+
if (log === undefined)
|
|
261
|
+
return ". Its output is above";
|
|
262
|
+
return log.written ? `. Its output is in ${log.file}` : "";
|
|
263
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
2
|
+
import { tmpdir, userInfo } from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { create } from "./create.js";
|
|
@@ -46,16 +46,18 @@ switch (parsed.kind) {
|
|
|
46
46
|
}
|
|
47
47
|
function usage(message) {
|
|
48
48
|
if (wantsJson) {
|
|
49
|
-
process.stdout.write(`${JSON.stringify({ ok: false, kind: "usage", message }, null, 2)}\n`);
|
|
49
|
+
process.stdout.write(`${JSON.stringify({ ok: false, kind: "usage", message, log: null }, null, 2)}\n`);
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
52
|
process.stderr.write(`create-creact: ${message}\n`);
|
|
53
53
|
}
|
|
54
54
|
process.exitCode = EXIT.usage;
|
|
55
55
|
}
|
|
56
|
-
// One file per project name, in the OS temp dir, so a rerun
|
|
57
|
-
// a failure before the project exists still has somewhere to
|
|
56
|
+
// One file per user and project name, in the OS temp dir, so a rerun
|
|
57
|
+
// replaces it, a failure before the project exists still has somewhere to
|
|
58
|
+
// write, and two users sharing /tmp don't collide.
|
|
58
59
|
function logFile(dir) {
|
|
59
60
|
const name = path.basename(dir).replaceAll(/[^\w.-]/g, "_");
|
|
60
|
-
|
|
61
|
+
const user = process.getuid?.() ?? userInfo().username;
|
|
62
|
+
return path.join(tmpdir(), `create-creact-${user}-${name}.log`);
|
|
61
63
|
}
|
package/dist/shell.js
CHANGED
|
@@ -13,10 +13,13 @@ const TAIL_LINES = 12;
|
|
|
13
13
|
// Where the commands' own output goes, so the terminal shows only
|
|
14
14
|
// create-creact's steps. A failure shows the last lines of the command that
|
|
15
15
|
// failed, and the file keeps the rest.
|
|
16
|
-
// The file starts empty on a run's first command, so it holds one run.
|
|
16
|
+
// The file starts empty on a run's first command, so it holds one run. A
|
|
17
|
+
// file it can't write, as one another user left in a shared temp dir, turns
|
|
18
|
+
// the log off rather than failing the run.
|
|
17
19
|
export class Log {
|
|
18
20
|
file;
|
|
19
21
|
#written = false;
|
|
22
|
+
#broken = false;
|
|
20
23
|
constructor(file) {
|
|
21
24
|
this.file = file;
|
|
22
25
|
}
|
|
@@ -24,13 +27,21 @@ export class Log {
|
|
|
24
27
|
return this.#written;
|
|
25
28
|
}
|
|
26
29
|
write(text) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
if (this.#broken)
|
|
31
|
+
return;
|
|
32
|
+
try {
|
|
33
|
+
/* oxlint-disable security/detect-non-literal-fs-filename -- a file in the OS temp dir, named by main */
|
|
34
|
+
if (this.#written)
|
|
35
|
+
appendFileSync(this.file, text);
|
|
36
|
+
else
|
|
37
|
+
writeFileSync(this.file, text);
|
|
38
|
+
/* oxlint-enable security/detect-non-literal-fs-filename -- the write ends here */
|
|
39
|
+
this.#written = true;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
this.#broken = true;
|
|
43
|
+
this.#written = false;
|
|
44
|
+
}
|
|
34
45
|
}
|
|
35
46
|
}
|
|
36
47
|
const NO_PROMPTS_OUTPUT_TO_STDERR = ["ignore", 2, 2];
|
package/dist/ui.js
CHANGED
|
@@ -280,8 +280,9 @@ function plain(log) {
|
|
|
280
280
|
}
|
|
281
281
|
},
|
|
282
282
|
succeeded(final) {
|
|
283
|
-
if (typeof final.skills === "object")
|
|
283
|
+
if (typeof final.skills === "object" && log.written) {
|
|
284
284
|
outLine(`log: ${log.file}`);
|
|
285
|
+
}
|
|
285
286
|
outLine(`next: cd ${shellQuoted(final.dir)} && pnpm dev`);
|
|
286
287
|
},
|
|
287
288
|
failed(error, kind) {
|
|
@@ -379,7 +380,7 @@ function rich(log, cwd) {
|
|
|
379
380
|
for (const command of next)
|
|
380
381
|
out(` ${color("cyan", command)}\n`);
|
|
381
382
|
}
|
|
382
|
-
if (typeof report.skills === "object") {
|
|
383
|
+
if (typeof report.skills === "object" && log.written) {
|
|
383
384
|
const where = `Full output: ${log.file}`;
|
|
384
385
|
out(`\n ${color("dim", where)}\n`);
|
|
385
386
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-creact",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Set up a React project with creact's lint, format, tsconfig, git hooks and tests",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"create",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"author": "Joshua Booth",
|
|
23
23
|
"type": "module",
|
|
24
24
|
"bin": {
|
|
25
|
-
"create-creact": "
|
|
25
|
+
"create-creact": "dist/main.js"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|