@project-selene/create-mod 0.0.8 → 0.1.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.
Files changed (2) hide show
  1. package/dist/main.mjs +11 -10
  2. package/package.json +1 -1
package/dist/main.mjs CHANGED
@@ -30,13 +30,15 @@ async function copyDir(src, dest) {
30
30
  }
31
31
  async function runNpmInstall(cwd) {
32
32
  return new Promise((resolve, reject) => {
33
- const child = spawn("npm", ["install"], { cwd, stdio: "inherit" });
33
+ const child = spawn("npm install", { cwd, stdio: "inherit", shell: process.platform === "win32" });
34
+ child.on("error", reject);
34
35
  child.on("close", (code) => code === 0 ? resolve() : reject(new Error("npm install failed")));
35
36
  });
36
37
  }
37
38
  async function runGitInit(cwd) {
38
39
  return new Promise((resolve, reject) => {
39
- const child = spawn("git", ["init"], { cwd, stdio: "inherit" });
40
+ const child = spawn("git init", { cwd, stdio: "inherit", shell: process.platform === "win32" });
41
+ child.on("error", reject);
40
42
  child.on("close", (code) => code === 0 ? resolve() : reject(new Error("git init failed")));
41
43
  });
42
44
  }
@@ -53,19 +55,19 @@ async function askPackageFields(providedBase) {
53
55
  const result = Object.assign({}, providedBase);
54
56
  const prompts = [];
55
57
  if (!providedBase.name) {
56
- prompts.push({ name: "name", message: descriptions.name, type: "input" });
58
+ prompts.push({ name: "name", message: descriptions.name + ":", type: "input" });
57
59
  }
58
60
  if (!providedBase.description) {
59
- prompts.push({ name: "description", message: descriptions.description, type: "input" });
61
+ prompts.push({ name: "description", message: descriptions.description + ":", type: "input" });
60
62
  }
61
63
  if (!providedBase.author) {
62
- prompts.push({ name: "author", message: descriptions.author, type: "input" });
64
+ prompts.push({ name: "author", message: descriptions.author + ":", type: "input" });
63
65
  }
64
66
  if (!providedBase.packageName) {
65
67
  const defaultPackageName = providedBase.name ? providedBase.name.toLowerCase().replace(/\s+/g, "-") : void 0;
66
68
  prompts.push({
67
69
  name: "packageName",
68
- message: descriptions.packageName,
70
+ message: descriptions.packageName + ":",
69
71
  type: "input",
70
72
  default: defaultPackageName,
71
73
  validate: (input) => {
@@ -88,7 +90,6 @@ async function askPackageFields(providedBase) {
88
90
  async function applyPackageFields(pkgPath, raw, provided) {
89
91
  const replaced = raw.replace(/<package-name>/g, provided.packageName || "").replace(/<description>/g, provided.description || "").replace(/<author>/g, provided.author || "").replace(/<uuid>/g, uuidv4()).replace(/<name>/g, provided.name || "");
90
92
  await fsp.writeFile(pkgPath, replaced, "utf8");
91
- console.log("Replaced tokens in package.json.");
92
93
  }
93
94
  async function main() {
94
95
  const program = new Command();
@@ -119,8 +120,8 @@ async function main() {
119
120
  packageName: opts.packageName
120
121
  };
121
122
  const provided = await askPackageFields(providedBase);
123
+ console.log("Copying template to", destPath, "...");
122
124
  await copyDir(templatePath, destPath);
123
- console.log("Template copied to", destPath);
124
125
  const pkgPath = path.join(destPath, "package.json");
125
126
  const pkgExists = await fsp.stat(pkgPath).then(() => true).catch(() => false);
126
127
  if (pkgExists) {
@@ -130,8 +131,8 @@ async function main() {
130
131
  console.log("Installing dependencies...");
131
132
  await runNpmInstall(destPath);
132
133
  console.log("Installing git repository...");
133
- await runGitInit(destPath);
134
- console.log("Done. Project initialized at", destPath);
134
+ await runGitInit(destPath).catch(() => console.warn("Git initialization failed"));
135
+ console.log("Done.");
135
136
  } catch (err) {
136
137
  console.error("Error:", err.message || err);
137
138
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@project-selene/create-mod",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
4
4
  "description": "A script for creating new Alabaster Dawn mods.",
5
5
  "main": "dist/main.mjs",
6
6
  "bin": "dist/main.mjs",