create-gtkx 1.6.0 → 2.0.0-beta.10

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/src/manifest.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { readFileSync, renameSync, writeFileSync } from "node:fs";
1
+ import { randomUUID } from "node:crypto";
2
+ import { readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
2
3
  import { join } from "node:path";
3
4
 
4
5
  const PACKAGE_JSON_FILE = "package.json";
@@ -7,9 +8,14 @@ const updateManifest = (root: string, mutate: (manifest: Record<string, unknown>
7
8
  const manifestPath = join(root, PACKAGE_JSON_FILE);
8
9
  const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as Record<string, unknown>;
9
10
  mutate(manifest);
10
- const pendingPath = `${manifestPath}.pending`;
11
- writeFileSync(pendingPath, `${JSON.stringify(manifest, null, 4)}\n`);
12
- renameSync(pendingPath, manifestPath);
11
+ const pendingPath = join(root, `.package-${randomUUID()}.json`);
12
+
13
+ try {
14
+ writeFileSync(pendingPath, `${JSON.stringify(manifest, null, 4)}\n`, { flag: "wx", mode: 0o600 });
15
+ renameSync(pendingPath, manifestPath);
16
+ } finally {
17
+ rmSync(pendingPath, { force: true });
18
+ }
13
19
  };
14
20
 
15
21
  export { updateManifest };
@@ -1,9 +1,30 @@
1
1
  type PackageManager = (typeof PACKAGE_MANAGERS)[number]["value"];
2
2
 
3
3
  const PACKAGE_MANAGERS = [
4
- { value: "pnpm", label: "pnpm", devCommand: "pnpm dev", addCommand: "pnpm add", isRecommended: true },
5
- { value: "npm", label: "npm", devCommand: "npm run dev", addCommand: "npm install", isRecommended: false },
6
- { value: "yarn", label: "yarn", devCommand: "yarn dev", addCommand: "yarn add", isRecommended: false },
4
+ {
5
+ value: "pnpm",
6
+ label: "pnpm",
7
+ devCommand: "pnpm dev",
8
+ addCommand: "pnpm add",
9
+ installCommand: "pnpm install",
10
+ isRecommended: true,
11
+ },
12
+ {
13
+ value: "npm",
14
+ label: "npm",
15
+ devCommand: "npm run dev",
16
+ addCommand: "npm install",
17
+ installCommand: "npm install",
18
+ isRecommended: false,
19
+ },
20
+ {
21
+ value: "yarn",
22
+ label: "yarn",
23
+ devCommand: "yarn dev",
24
+ addCommand: "yarn add",
25
+ installCommand: "yarn install",
26
+ isRecommended: false,
27
+ },
7
28
  ] as const;
8
29
 
9
30
  const PACKAGE_MANAGER_VALUES: PackageManager[] = PACKAGE_MANAGERS.map((manager) => manager.value);