create-adonisjs 3.1.0 → 3.2.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/build/bin/run.js
CHANGED
|
@@ -84,26 +84,39 @@ var CreateNewApp = class extends BaseCommand {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Adapts the downloaded starter kit for the detected package manager.
|
|
87
|
-
*
|
|
88
|
-
* - For
|
|
89
|
-
* - For
|
|
87
|
+
* - For non-pnpm package managers: removes pnpm-workspace.yaml
|
|
88
|
+
* - For non-monorepo starter kits: no further changes are needed
|
|
89
|
+
* - For pnpm monorepos: removes the workspaces field from package.json
|
|
90
|
+
* since pnpm uses pnpm-workspace.yaml for workspace configuration
|
|
91
|
+
* - For monorepos: sets the packageManager field in package.json to the
|
|
92
|
+
* detected package manager name and version
|
|
90
93
|
*/
|
|
91
94
|
async #adaptForPackageManager() {
|
|
92
95
|
const pkgJsonPath = join(this.destination, "package.json");
|
|
93
96
|
const pkgJson = await readFile(pkgJsonPath, "utf-8").then(JSON.parse);
|
|
97
|
+
const pnpmWorkspacePath = join(this.destination, "pnpm-workspace.yaml");
|
|
98
|
+
if (this.packageManager !== "pnpm") {
|
|
99
|
+
try {
|
|
100
|
+
await unlink(pnpmWorkspacePath);
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!this.isMonorepo) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
94
107
|
let dirty = false;
|
|
95
|
-
if (this.
|
|
96
|
-
const lines = ["packages:"];
|
|
97
|
-
for (const pattern of pkgJson.workspaces) lines.push(` - '${pattern}'`);
|
|
98
|
-
await writeFile(join(this.destination, "pnpm-workspace.yaml"), lines.join("\n") + "\n");
|
|
108
|
+
if (this.packageManager === "pnpm") {
|
|
99
109
|
delete pkgJson.workspaces;
|
|
100
110
|
dirty = true;
|
|
101
111
|
}
|
|
102
|
-
|
|
103
|
-
|
|
112
|
+
const detectedPackageManager = detectPackageManager();
|
|
113
|
+
if (detectedPackageManager) {
|
|
114
|
+
pkgJson.packageManager = `${detectedPackageManager.name}@${detectedPackageManager.version}`;
|
|
104
115
|
dirty = true;
|
|
105
116
|
}
|
|
106
|
-
if (dirty)
|
|
117
|
+
if (dirty) {
|
|
118
|
+
await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
|
|
119
|
+
}
|
|
107
120
|
}
|
|
108
121
|
/**
|
|
109
122
|
* Executes a bash command using execa with shared default options.
|
package/build/index.js
CHANGED