@meistrari/mise-en-place 2.7.1 → 2.9.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.
- package/Makefile +7 -6
- package/dist/cli/cli.mjs +105 -6
- package/package.json +2 -1
package/Makefile
CHANGED
|
@@ -3,10 +3,7 @@ default: help
|
|
|
3
3
|
|
|
4
4
|
_MISE_EN_PLACE_PACKAGE_NAME = @meistrari/mise-en-place
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.editorconfig: ./node_modules/$(_MISE_EN_PLACE_PACKAGE_NAME)/.editorconfig ## Copy/update .editorconfig file from @meistrari/mise-en-place package
|
|
9
|
-
@cp ./node_modules/$(_MISE_EN_PLACE_PACKAGE_NAME)/.editorconfig .editorconfig
|
|
6
|
+
# region Public commands
|
|
10
7
|
|
|
11
8
|
.PHONY: update-meistrari-libs
|
|
12
9
|
update-meistrari-libs: ## Update @meistrari/* packages recursively in the workspace
|
|
@@ -14,13 +11,17 @@ update-meistrari-libs: ## Update @meistrari/* packages recursively in the worksp
|
|
|
14
11
|
|
|
15
12
|
.PHONY: mise-en-place
|
|
16
13
|
mise-en-place: .editorconfig ## Setup the mise en place to start cooking
|
|
17
|
-
@
|
|
14
|
+
@npx mise-en-place postinstall
|
|
18
15
|
@echo "Mise en place is ready! 🍳"
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
# endregion
|
|
18
|
+
|
|
19
|
+
# region Hidden
|
|
21
20
|
|
|
22
21
|
.PHONY: help
|
|
23
22
|
help:
|
|
24
23
|
@echo "Make tasks:"
|
|
25
24
|
@grep -hE '^[%a-zA-Z_-]+:.*?## .*$$' Makefile ./node_modules/$(_MISE_EN_PLACE_PACKAGE_NAME)/Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-17s\033[0m %s\n", $$1, $$2}'
|
|
26
25
|
@echo ""
|
|
26
|
+
|
|
27
|
+
# endregion
|
package/dist/cli/cli.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { argv } from 'node:process';
|
|
3
3
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { execSync } from 'node:child_process';
|
|
5
4
|
import { globSync } from 'glob';
|
|
5
|
+
import { execSync } from 'node:child_process';
|
|
6
6
|
import { dirname } from 'node:path';
|
|
7
7
|
import { parse } from 'yaml';
|
|
8
8
|
|
|
@@ -209,17 +209,116 @@ function updateMeistrariLibraries(args) {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
const name = "@meistrari/mise-en-place";
|
|
213
|
+
const packageJson = {
|
|
214
|
+
name: name};
|
|
215
|
+
|
|
216
|
+
const {
|
|
217
|
+
name: packageName
|
|
218
|
+
} = packageJson;
|
|
219
|
+
const oldMakefileIncludeLine = "include ./node_modules/@meistrari/mise-en-place/Makefile";
|
|
220
|
+
const makeFileIncludeLine = "-include ./node_modules/@meistrari/mise-en-place/Makefile";
|
|
212
221
|
function handleMakefileInitialSetup() {
|
|
213
|
-
if (existsSync("Makefile")) {
|
|
214
|
-
console.log("Makefile
|
|
222
|
+
if (!existsSync("Makefile")) {
|
|
223
|
+
console.log("No Makefile found. Generating one that includes mise-en-place Makefile.");
|
|
224
|
+
writeFileSync("Makefile", `${makeFileIncludeLine}
|
|
225
|
+
`);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const makefileContent = readFileSync("Makefile", "utf-8");
|
|
229
|
+
if (makefileContent.includes(makeFileIncludeLine.trim())) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (makefileContent.includes(oldMakefileIncludeLine)) {
|
|
233
|
+
console.log();
|
|
234
|
+
writeFileSync("Makefile", makefileContent.replace(oldMakefileIncludeLine, makeFileIncludeLine));
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
console.log("Adding mise-en-place Makefile include to existing Makefile.");
|
|
238
|
+
const newContent = `${makeFileIncludeLine}
|
|
239
|
+
|
|
240
|
+
${makefileContent}`;
|
|
241
|
+
writeFileSync("Makefile", newContent);
|
|
242
|
+
}
|
|
243
|
+
const miseEnPlaceTsConfigExtends = "./node_modules/@meistrari/mise-en-place/tsconfig.base.json";
|
|
244
|
+
function handleTsConfig() {
|
|
245
|
+
if (!existsSync("tsconfig.json")) {
|
|
246
|
+
console.log("No tsconfig.json found. Generating one that extends mise-en-place tsconfig.json.");
|
|
247
|
+
writeFileSync(
|
|
248
|
+
"tsconfig.json",
|
|
249
|
+
`{ "extends": "${miseEnPlaceTsConfigExtends}" }
|
|
250
|
+
`
|
|
251
|
+
);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const tsconfigRaw = readFileSync("tsconfig.json", "utf-8");
|
|
255
|
+
const tsconfigContent = JSON.parse(tsconfigRaw);
|
|
256
|
+
if (!tsconfigContent.extends) {
|
|
257
|
+
console.log("tsconfig.json has no extends field. Adding mise-en-place tsconfig as extends.");
|
|
258
|
+
tsconfigContent.extends = miseEnPlaceTsConfigExtends;
|
|
259
|
+
writeFileSync("tsconfig.json", `${JSON.stringify(tsconfigContent, null, 4)}
|
|
260
|
+
`);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (typeof tsconfigContent.extends === "string") {
|
|
264
|
+
if (tsconfigContent.extends === miseEnPlaceTsConfigExtends) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
console.log("tsconfig.json extends is a string. Converting to array and adding mise-en-place tsconfig.");
|
|
268
|
+
tsconfigContent.extends = [tsconfigContent.extends, miseEnPlaceTsConfigExtends];
|
|
269
|
+
writeFileSync("tsconfig.json", `${JSON.stringify(tsconfigContent, null, 4)}
|
|
270
|
+
`);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (Array.isArray(tsconfigContent.extends)) {
|
|
274
|
+
if (tsconfigContent.extends.includes(miseEnPlaceTsConfigExtends)) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
console.log("tsconfig.json extends is an array. Adding mise-en-place tsconfig to the extends array.");
|
|
278
|
+
tsconfigContent.extends.push(miseEnPlaceTsConfigExtends);
|
|
279
|
+
writeFileSync("tsconfig.json", `${JSON.stringify(tsconfigContent, null, 4)}
|
|
280
|
+
`);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
console.error(tsconfigContent.extends);
|
|
284
|
+
throw new Error("Unhandled tsconfig.json extends field type");
|
|
285
|
+
}
|
|
286
|
+
function handleEslintConfigFile() {
|
|
287
|
+
const eslintContent = `export { default } from '${packageName}/eslint'
|
|
288
|
+
`;
|
|
289
|
+
writeFileSync("eslint.config.mjs", eslintContent);
|
|
290
|
+
}
|
|
291
|
+
function handleEditorconfigFile() {
|
|
292
|
+
const editorconfigContent = readFileSync(`./node_modules/${packageName}/.editorconfig`, "utf-8");
|
|
293
|
+
writeFileSync(".editorconfig", editorconfigContent);
|
|
294
|
+
}
|
|
295
|
+
function handlePackageJsonScripts() {
|
|
296
|
+
if (!existsSync("package.json")) {
|
|
297
|
+
throw new Error("No package.json found. Skipping package.json scripts setup.");
|
|
298
|
+
}
|
|
299
|
+
const packageJsonRaw = readFileSync("package.json", "utf-8");
|
|
300
|
+
const packageJsonContent = JSON.parse(packageJsonRaw);
|
|
301
|
+
if (!packageJsonContent.scripts) {
|
|
302
|
+
packageJsonContent.scripts = {};
|
|
303
|
+
}
|
|
304
|
+
const {
|
|
305
|
+
postinstall: currentPostinstallScript
|
|
306
|
+
} = packageJsonContent.scripts;
|
|
307
|
+
const miseEnPlacePostinstallScript = "mise-en-place postinstall";
|
|
308
|
+
if (currentPostinstallScript?.includes(miseEnPlacePostinstallScript)) {
|
|
215
309
|
return;
|
|
216
310
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
311
|
+
const newPostinstallScript = currentPostinstallScript ? `${miseEnPlacePostinstallScript} && ${currentPostinstallScript}` : miseEnPlacePostinstallScript;
|
|
312
|
+
packageJsonContent.scripts.postinstall = newPostinstallScript;
|
|
313
|
+
writeFileSync("package.json", `${JSON.stringify(packageJsonContent, null, 4)}
|
|
314
|
+
`);
|
|
220
315
|
}
|
|
221
316
|
function postinstall(args) {
|
|
222
317
|
handleMakefileInitialSetup();
|
|
318
|
+
handleTsConfig();
|
|
319
|
+
handleEslintConfigFile();
|
|
320
|
+
handleEditorconfigFile();
|
|
321
|
+
handlePackageJsonScripts();
|
|
223
322
|
updateMeistrariLibraries(args);
|
|
224
323
|
}
|
|
225
324
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meistrari/mise-en-place",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"homepage": "https://github.com/meistrari/mise-en-place#readme",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@antfu/eslint-config": "6.2.0",
|
|
38
|
+
"dedent": "1.7.1",
|
|
38
39
|
"eslint": "9.39.1",
|
|
39
40
|
"eslint-plugin-diff": "2.0.3",
|
|
40
41
|
"eslint-plugin-drizzle": "0.2.3",
|