create-newt-app 0.22.4 → 0.22.5
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 +38 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import chalk from "chalk";
|
|
|
7
7
|
// package.json
|
|
8
8
|
var package_default = {
|
|
9
9
|
name: "create-newt-app",
|
|
10
|
-
version: "0.22.
|
|
10
|
+
version: "0.22.5",
|
|
11
11
|
private: false,
|
|
12
12
|
type: "module",
|
|
13
13
|
bin: {
|
|
@@ -131,6 +131,42 @@ async function renderTemplatesToDisk(basePackages, destDir, templateData) {
|
|
|
131
131
|
}
|
|
132
132
|
}, Promise.resolve());
|
|
133
133
|
}
|
|
134
|
+
var DEP_FIELDS = [
|
|
135
|
+
"dependencies",
|
|
136
|
+
"devDependencies",
|
|
137
|
+
"peerDependencies",
|
|
138
|
+
"optionalDependencies"
|
|
139
|
+
];
|
|
140
|
+
function sortByKey(obj) {
|
|
141
|
+
return Object.fromEntries(
|
|
142
|
+
Object.keys(obj).sort().map((key) => [key, obj[key]])
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
async function sortPackageJsons(destDir) {
|
|
146
|
+
const nested = await Promise.all(
|
|
147
|
+
["apps", "packages"].map(async (base) => {
|
|
148
|
+
const dir = path.join(destDir, base);
|
|
149
|
+
try {
|
|
150
|
+
const entries = await promises.readdir(dir, { withFileTypes: true });
|
|
151
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => path.join(dir, entry.name, "package.json"));
|
|
152
|
+
} catch {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
);
|
|
157
|
+
const files = [path.join(destDir, "package.json")].concat(...nested);
|
|
158
|
+
await Promise.all(
|
|
159
|
+
files.map(async (file) => {
|
|
160
|
+
if (!existsSync(file)) return;
|
|
161
|
+
const pkg = JSON.parse(await promises.readFile(file, "utf8"));
|
|
162
|
+
if (pkg.scripts) pkg.scripts = sortByKey(pkg.scripts);
|
|
163
|
+
DEP_FIELDS.forEach((field) => {
|
|
164
|
+
if (pkg[field]) pkg[field] = sortByKey(pkg[field]);
|
|
165
|
+
});
|
|
166
|
+
await promises.writeFile(file, JSON.stringify(pkg, null, 2) + "\n");
|
|
167
|
+
})
|
|
168
|
+
);
|
|
169
|
+
}
|
|
134
170
|
function validateProjectName(projectName) {
|
|
135
171
|
if (!projectName) {
|
|
136
172
|
return { valid: false, error: "Project name is required" };
|
|
@@ -180,6 +216,7 @@ async function scaffold(modules, options) {
|
|
|
180
216
|
if (scripts.length > 0) {
|
|
181
217
|
await updateScripts(options.name, scripts, templateData);
|
|
182
218
|
}
|
|
219
|
+
await sortPackageJsons(options.name);
|
|
183
220
|
}
|
|
184
221
|
async function pnpmInstall(cwd) {
|
|
185
222
|
return await execa("pnpm", ["install"], {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-newt-app",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"ejs": "^3.1.10",
|
|
17
17
|
"execa": "^9.6.0",
|
|
18
18
|
"zod": "^3.25.76",
|
|
19
|
-
"@newt-app/templates": "0.22.
|
|
19
|
+
"@newt-app/templates": "0.22.5"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/ejs": "^3.1.5",
|