create-alistt69-kit 0.1.11 → 0.1.12
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/LICENSE +20 -20
- package/README.md +123 -123
- package/bin/index.js +24 -24
- package/package.json +44 -44
- package/src/core/apply-features.js +14 -14
- package/src/core/collect-project-info.js +170 -170
- package/src/core/copy-base-template.js +11 -11
- package/src/core/create-project.js +99 -99
- package/src/core/install-dependencies.js +27 -27
- package/src/core/parse-cli-args.js +122 -122
- package/src/core/prepare-target-directory.js +69 -69
- package/src/core/render-project-readme.js +188 -188
- package/src/core/replace-tokens.js +45 -45
- package/src/core/restore-special-files.js +18 -18
- package/src/features/autoprefixer/files/postcss.config.cjs +4 -4
- package/src/features/autoprefixer/index.js +18 -18
- package/src/features/define-feature.js +32 -32
- package/src/features/eslint/files/eslint.config.mjs +133 -133
- package/src/features/eslint/index.js +29 -29
- package/src/features/index.js +24 -24
- package/src/features/react-router/files/src/app/App.tsx +20 -20
- package/src/features/react-router/files/src/app/layouts/app/index.tsx +36 -36
- package/src/features/react-router/files/src/app/providers/router/config/router.tsx +13 -13
- package/src/features/react-router/files/src/pages/error/index.ts +1 -1
- package/src/features/react-router/files/src/pages/error/lazy.ts +3 -3
- package/src/features/react-router/files/src/pages/error/page.tsx +7 -7
- package/src/features/react-router/files/src/pages/main/index.ts +1 -1
- package/src/features/react-router/files/src/pages/main/lazy.ts +3 -3
- package/src/features/react-router/files/src/pages/main/page.tsx +7 -7
- package/src/features/react-router/index.js +18 -18
- package/src/features/stylelint/files/stylelint.config.mjs +13 -13
- package/src/features/stylelint/index.js +23 -23
- package/src/templates/base/.editorconfig +11 -11
- package/src/templates/base/README.md +2 -2
- package/src/templates/base/babel.config.json +12 -12
- package/src/templates/base/gitignore +27 -27
- package/src/templates/base/package.json +48 -48
- package/src/templates/base/public/index.html +12 -12
- package/src/templates/base/src/app/App.tsx +17 -17
- package/src/templates/base/src/index.tsx +16 -16
- package/src/templates/base/src/styles/index.scss +13 -13
- package/src/templates/base/tsconfig.json +25 -25
- package/src/utils/console-format.js +11 -11
- package/src/utils/package-json.js +96 -96
- package/src/utils/package-manager.js +22 -22
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { dirname, resolve } from 'node:path';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
|
|
4
|
-
import { defineFeature } from '../define-feature.js';
|
|
5
|
-
|
|
6
|
-
const currentFilePath = fileURLToPath(import.meta.url);
|
|
7
|
-
const currentDirPath = dirname(currentFilePath);
|
|
8
|
-
|
|
9
|
-
export const stylelintFeature = defineFeature({
|
|
10
|
-
id: 'stylelint',
|
|
11
|
-
title: 'Stylelint',
|
|
12
|
-
hint: 'SCSS/CSS linting',
|
|
13
|
-
packageJson: {
|
|
14
|
-
devDependencies: {
|
|
15
|
-
stylelint: '^17.6.0',
|
|
16
|
-
'stylelint-config-standard-scss': '^17.0.0',
|
|
17
|
-
},
|
|
18
|
-
scripts: {
|
|
19
|
-
'lint:styles': 'stylelint "src/**/*.{scss,css}"',
|
|
20
|
-
'lint:styles:fix': 'stylelint "src/**/*.{scss,css}" --fix',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
copyFiles: resolve(currentDirPath, 'files'),
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
import { defineFeature } from '../define-feature.js';
|
|
5
|
+
|
|
6
|
+
const currentFilePath = fileURLToPath(import.meta.url);
|
|
7
|
+
const currentDirPath = dirname(currentFilePath);
|
|
8
|
+
|
|
9
|
+
export const stylelintFeature = defineFeature({
|
|
10
|
+
id: 'stylelint',
|
|
11
|
+
title: 'Stylelint',
|
|
12
|
+
hint: 'SCSS/CSS linting',
|
|
13
|
+
packageJson: {
|
|
14
|
+
devDependencies: {
|
|
15
|
+
stylelint: '^17.6.0',
|
|
16
|
+
'stylelint-config-standard-scss': '^17.0.0',
|
|
17
|
+
},
|
|
18
|
+
scripts: {
|
|
19
|
+
'lint:styles': 'stylelint "src/**/*.{scss,css}"',
|
|
20
|
+
'lint:styles:fix': 'stylelint "src/**/*.{scss,css}" --fix',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
copyFiles: resolve(currentDirPath, 'files'),
|
|
24
24
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
root = true
|
|
2
|
-
|
|
3
|
-
[*]
|
|
4
|
-
charset = utf-8
|
|
5
|
-
indent_style = space
|
|
6
|
-
indent_size = 4
|
|
7
|
-
end_of_line = lf
|
|
8
|
-
insert_final_newline = true
|
|
9
|
-
trim_trailing_whitespace = true
|
|
10
|
-
|
|
11
|
-
[*.md]
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
indent_style = space
|
|
6
|
+
indent_size = 4
|
|
7
|
+
end_of_line = lf
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.md]
|
|
12
12
|
trim_trailing_whitespace = false
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# __PROJECT_NAME__
|
|
2
|
-
|
|
1
|
+
# __PROJECT_NAME__
|
|
2
|
+
|
|
3
3
|
Created with create-alistt69-kit
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"presets": [
|
|
3
|
-
"@babel/preset-env",
|
|
4
|
-
"@babel/preset-typescript",
|
|
5
|
-
[
|
|
6
|
-
"@babel/preset-react",
|
|
7
|
-
{
|
|
8
|
-
"runtime": "automatic"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
]
|
|
12
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"presets": [
|
|
3
|
+
"@babel/preset-env",
|
|
4
|
+
"@babel/preset-typescript",
|
|
5
|
+
[
|
|
6
|
+
"@babel/preset-react",
|
|
7
|
+
{
|
|
8
|
+
"runtime": "automatic"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
]
|
|
12
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
# Local-specified
|
|
2
|
-
node_modules
|
|
3
|
-
dist
|
|
4
|
-
build
|
|
5
|
-
coverage
|
|
6
|
-
.env
|
|
7
|
-
.env.local
|
|
8
|
-
|
|
9
|
-
# Editor directories and files
|
|
10
|
-
.vscode/*
|
|
11
|
-
!.vscode/extensions.json
|
|
12
|
-
.idea
|
|
13
|
-
.DS_Store
|
|
14
|
-
*.suo
|
|
15
|
-
*.ntvs*
|
|
16
|
-
*.njsproj
|
|
17
|
-
*.sln
|
|
18
|
-
*.sw?
|
|
19
|
-
|
|
20
|
-
# Logs
|
|
21
|
-
logs
|
|
22
|
-
*.log
|
|
23
|
-
npm-debug.log*
|
|
24
|
-
yarn-debug.log*
|
|
25
|
-
yarn-error.log*
|
|
26
|
-
pnpm-debug.log*
|
|
27
|
-
lerna-debug.log*
|
|
1
|
+
# Local-specified
|
|
2
|
+
node_modules
|
|
3
|
+
dist
|
|
4
|
+
build
|
|
5
|
+
coverage
|
|
6
|
+
.env
|
|
7
|
+
.env.local
|
|
8
|
+
|
|
9
|
+
# Editor directories and files
|
|
10
|
+
.vscode/*
|
|
11
|
+
!.vscode/extensions.json
|
|
12
|
+
.idea
|
|
13
|
+
.DS_Store
|
|
14
|
+
*.suo
|
|
15
|
+
*.ntvs*
|
|
16
|
+
*.njsproj
|
|
17
|
+
*.sln
|
|
18
|
+
*.sw?
|
|
19
|
+
|
|
20
|
+
# Logs
|
|
21
|
+
logs
|
|
22
|
+
*.log
|
|
23
|
+
npm-debug.log*
|
|
24
|
+
yarn-debug.log*
|
|
25
|
+
yarn-error.log*
|
|
26
|
+
pnpm-debug.log*
|
|
27
|
+
lerna-debug.log*
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "__PROJECT_NAME__",
|
|
3
|
-
"version": "0.0.1",
|
|
4
|
-
"private": true,
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "webpack --env mode=production",
|
|
7
|
-
"build:dev": "webpack --env mode=development",
|
|
8
|
-
"build:prod": "webpack --env mode=production",
|
|
9
|
-
"dev": "webpack serve --env mode=development port=3000",
|
|
10
|
-
"start": "webpack serve --env mode=development port=3000",
|
|
11
|
-
"typecheck": "tsc --noEmit"
|
|
12
|
-
},
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"clsx": "^2.1.1",
|
|
15
|
-
"react": "^18.3.1",
|
|
16
|
-
"react-dom": "^18.3.1"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@babel/core": "^7.26.0",
|
|
20
|
-
"@babel/preset-react": "^7.25.9",
|
|
21
|
-
"@babel/preset-typescript": "^7.26.0",
|
|
22
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
|
|
23
|
-
"@svgr/webpack": "^8.1.0",
|
|
24
|
-
"@types/node": "^22.10.1",
|
|
25
|
-
"@types/react": "^18.3.12",
|
|
26
|
-
"@types/react-dom": "^18.3.1",
|
|
27
|
-
"@types/webpack": "^5.28.5",
|
|
28
|
-
"@types/webpack-bundle-analyzer": "^4.7.0",
|
|
29
|
-
"@types/webpack-dev-server": "^4.7.1",
|
|
30
|
-
"babel-loader": "^9.2.1",
|
|
31
|
-
"css-loader": "^6.11.0",
|
|
32
|
-
"html-webpack-plugin": "^5.6.3",
|
|
33
|
-
"mini-css-extract-plugin": "^2.9.2",
|
|
34
|
-
"postcss": "^8.5.6",
|
|
35
|
-
"postcss-loader": "^8.2.0",
|
|
36
|
-
"react-refresh": "^0.14.2",
|
|
37
|
-
"sass": "^1.81.0",
|
|
38
|
-
"sass-loader": "^16.0.3",
|
|
39
|
-
"style-loader": "^4.0.0",
|
|
40
|
-
"ts-loader": "^9.5.1",
|
|
41
|
-
"ts-node": "^10.9.2",
|
|
42
|
-
"typescript": "^5.7.2",
|
|
43
|
-
"webpack": "^5.96.1",
|
|
44
|
-
"webpack-bundle-analyzer": "^4.10.2",
|
|
45
|
-
"webpack-cli": "^5.1.4",
|
|
46
|
-
"webpack-dev-server": "^5.1.0"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "__PROJECT_NAME__",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "webpack --env mode=production",
|
|
7
|
+
"build:dev": "webpack --env mode=development",
|
|
8
|
+
"build:prod": "webpack --env mode=production",
|
|
9
|
+
"dev": "webpack serve --env mode=development port=3000",
|
|
10
|
+
"start": "webpack serve --env mode=development port=3000",
|
|
11
|
+
"typecheck": "tsc --noEmit"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"clsx": "^2.1.1",
|
|
15
|
+
"react": "^18.3.1",
|
|
16
|
+
"react-dom": "^18.3.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@babel/core": "^7.26.0",
|
|
20
|
+
"@babel/preset-react": "^7.25.9",
|
|
21
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
22
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
|
|
23
|
+
"@svgr/webpack": "^8.1.0",
|
|
24
|
+
"@types/node": "^22.10.1",
|
|
25
|
+
"@types/react": "^18.3.12",
|
|
26
|
+
"@types/react-dom": "^18.3.1",
|
|
27
|
+
"@types/webpack": "^5.28.5",
|
|
28
|
+
"@types/webpack-bundle-analyzer": "^4.7.0",
|
|
29
|
+
"@types/webpack-dev-server": "^4.7.1",
|
|
30
|
+
"babel-loader": "^9.2.1",
|
|
31
|
+
"css-loader": "^6.11.0",
|
|
32
|
+
"html-webpack-plugin": "^5.6.3",
|
|
33
|
+
"mini-css-extract-plugin": "^2.9.2",
|
|
34
|
+
"postcss": "^8.5.6",
|
|
35
|
+
"postcss-loader": "^8.2.0",
|
|
36
|
+
"react-refresh": "^0.14.2",
|
|
37
|
+
"sass": "^1.81.0",
|
|
38
|
+
"sass-loader": "^16.0.3",
|
|
39
|
+
"style-loader": "^4.0.0",
|
|
40
|
+
"ts-loader": "^9.5.1",
|
|
41
|
+
"ts-node": "^10.9.2",
|
|
42
|
+
"typescript": "^5.7.2",
|
|
43
|
+
"webpack": "^5.96.1",
|
|
44
|
+
"webpack-bundle-analyzer": "^4.10.2",
|
|
45
|
+
"webpack-cli": "^5.1.4",
|
|
46
|
+
"webpack-dev-server": "^5.1.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/png" href="/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>artello</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root"></div>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/png" href="/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>artello</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import Logo from '../../public/create-alistt69-kit-logo.svg';
|
|
2
|
-
import styles from './styles.module.scss';
|
|
3
|
-
|
|
4
|
-
function App() {
|
|
5
|
-
return (
|
|
6
|
-
<div className={styles.app_wrapper}>
|
|
7
|
-
<div className={styles.created_by_section}>
|
|
8
|
-
<Logo className={styles.logo} />
|
|
9
|
-
<p className={styles.promo}>
|
|
10
|
-
created by create-alistt69-kit
|
|
11
|
-
</p>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default App;
|
|
1
|
+
import Logo from '../../public/create-alistt69-kit-logo.svg';
|
|
2
|
+
import styles from './styles.module.scss';
|
|
3
|
+
|
|
4
|
+
function App() {
|
|
5
|
+
return (
|
|
6
|
+
<div className={styles.app_wrapper}>
|
|
7
|
+
<div className={styles.created_by_section}>
|
|
8
|
+
<Logo className={styles.logo} />
|
|
9
|
+
<p className={styles.promo}>
|
|
10
|
+
created by create-alistt69-kit
|
|
11
|
+
</p>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default App;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { StrictMode } from 'react';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import App from './app/App';
|
|
4
|
-
import './styles/index.scss';
|
|
5
|
-
|
|
6
|
-
const container = document.getElementById('root');
|
|
7
|
-
|
|
8
|
-
if (!container) {
|
|
9
|
-
throw new Error('Root container not found');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
createRoot(container).render(
|
|
13
|
-
<StrictMode>
|
|
14
|
-
<App />
|
|
15
|
-
</StrictMode>,
|
|
16
|
-
);
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import App from './app/App';
|
|
4
|
+
import './styles/index.scss';
|
|
5
|
+
|
|
6
|
+
const container = document.getElementById('root');
|
|
7
|
+
|
|
8
|
+
if (!container) {
|
|
9
|
+
throw new Error('Root container not found');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
createRoot(container).render(
|
|
13
|
+
<StrictMode>
|
|
14
|
+
<App />
|
|
15
|
+
</StrictMode>,
|
|
16
|
+
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
html,
|
|
2
|
-
body,
|
|
3
|
-
#root {
|
|
4
|
-
margin: 0;
|
|
5
|
-
padding: 0;
|
|
6
|
-
min-height: 100%;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
body {
|
|
10
|
-
font-family: Bahnschrift;
|
|
11
|
-
background: #141617;
|
|
12
|
-
color: #A6A8AAFF;
|
|
13
|
-
}
|
|
1
|
+
html,
|
|
2
|
+
body,
|
|
3
|
+
#root {
|
|
4
|
+
margin: 0;
|
|
5
|
+
padding: 0;
|
|
6
|
+
min-height: 100%;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
body {
|
|
10
|
+
font-family: Bahnschrift;
|
|
11
|
+
background: #141617;
|
|
12
|
+
color: #A6A8AAFF;
|
|
13
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "./build",
|
|
4
|
-
"noImplicitAny": true,
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"target": "es6",
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
"allowJs": true,
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"allowSyntheticDefaultImports": true,
|
|
14
|
-
"esModuleInterop": true,
|
|
15
|
-
"baseUrl": "./",
|
|
16
|
-
"paths": {
|
|
17
|
-
"@/*": ["./src/*"]
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"ts-node": {
|
|
21
|
-
"compilerOptions": {
|
|
22
|
-
"module": "CommonJS"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./build",
|
|
4
|
+
"noImplicitAny": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"target": "es6",
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"allowSyntheticDefaultImports": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"baseUrl": "./",
|
|
16
|
+
"paths": {
|
|
17
|
+
"@/*": ["./src/*"]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"ts-node": {
|
|
21
|
+
"compilerOptions": {
|
|
22
|
+
"module": "CommonJS"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const color = (code, text) => `\u001B[${code}m${text}\u001B[0m`;
|
|
2
|
-
|
|
3
|
-
export const format = {
|
|
4
|
-
cyan: (text) => color('36', text),
|
|
5
|
-
green: (text) => color('32', text),
|
|
6
|
-
yellow: (text) => color('33', text),
|
|
7
|
-
dim: (text) => color('2', text),
|
|
8
|
-
bold: (text) => color('1', text),
|
|
9
|
-
|
|
10
|
-
sectionTitle: (text) => color('36', text),
|
|
11
|
-
label: (text) => color('2', text),
|
|
1
|
+
const color = (code, text) => `\u001B[${code}m${text}\u001B[0m`;
|
|
2
|
+
|
|
3
|
+
export const format = {
|
|
4
|
+
cyan: (text) => color('36', text),
|
|
5
|
+
green: (text) => color('32', text),
|
|
6
|
+
yellow: (text) => color('33', text),
|
|
7
|
+
dim: (text) => color('2', text),
|
|
8
|
+
bold: (text) => color('1', text),
|
|
9
|
+
|
|
10
|
+
sectionTitle: (text) => color('36', text),
|
|
11
|
+
label: (text) => color('2', text),
|
|
12
12
|
};
|
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { resolve } from 'node:path';
|
|
3
|
-
|
|
4
|
-
function sortRecordEntries(record) {
|
|
5
|
-
if (!record) {
|
|
6
|
-
return record;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return Object.fromEntries(
|
|
10
|
-
Object.entries(record).sort(([leftName], [rightName]) => (
|
|
11
|
-
leftName.localeCompare(rightName)
|
|
12
|
-
)),
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function mergeRecordEntries(currentRecord, entriesToAdd) {
|
|
17
|
-
if (!entriesToAdd || Object.keys(entriesToAdd).length === 0) {
|
|
18
|
-
return currentRecord;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return sortRecordEntries({
|
|
22
|
-
...(currentRecord ?? {}),
|
|
23
|
-
...entriesToAdd,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function normalizePackageJson(packageJson) {
|
|
28
|
-
packageJson.dependencies = sortRecordEntries(packageJson.dependencies);
|
|
29
|
-
packageJson.devDependencies = sortRecordEntries(packageJson.devDependencies);
|
|
30
|
-
packageJson.scripts = sortRecordEntries(packageJson.scripts);
|
|
31
|
-
|
|
32
|
-
return packageJson;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export async function readPackageJson(projectPath) {
|
|
36
|
-
const packageJsonPath = resolve(projectPath, 'package.json');
|
|
37
|
-
const content = await readFile(packageJsonPath, 'utf8');
|
|
38
|
-
|
|
39
|
-
return JSON.parse(content);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export async function writePackageJson(projectPath, packageJson) {
|
|
43
|
-
const packageJsonPath = resolve(projectPath, 'package.json');
|
|
44
|
-
|
|
45
|
-
await writeFile(
|
|
46
|
-
packageJsonPath,
|
|
47
|
-
`${JSON.stringify(normalizePackageJson(packageJson), null, 4)}\n`,
|
|
48
|
-
'utf8',
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export async function updatePackageJson(projectPath, updater) {
|
|
53
|
-
const packageJson = await readPackageJson(projectPath);
|
|
54
|
-
|
|
55
|
-
await updater(packageJson);
|
|
56
|
-
|
|
57
|
-
await writePackageJson(projectPath, packageJson);
|
|
58
|
-
|
|
59
|
-
return packageJson;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export async function patchPackageJson(projectPath, patch) {
|
|
63
|
-
return updatePackageJson(projectPath, (packageJson) => {
|
|
64
|
-
packageJson.dependencies = mergeRecordEntries(
|
|
65
|
-
packageJson.dependencies,
|
|
66
|
-
patch.dependencies,
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
packageJson.devDependencies = mergeRecordEntries(
|
|
70
|
-
packageJson.devDependencies,
|
|
71
|
-
patch.devDependencies,
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
packageJson.scripts = mergeRecordEntries(
|
|
75
|
-
packageJson.scripts,
|
|
76
|
-
patch.scripts,
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export async function addDependencies(projectPath, dependenciesToAdd) {
|
|
82
|
-
return patchPackageJson(projectPath, {
|
|
83
|
-
dependencies: dependenciesToAdd,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export async function addDevDependencies(projectPath, dependenciesToAdd) {
|
|
88
|
-
return patchPackageJson(projectPath, {
|
|
89
|
-
devDependencies: dependenciesToAdd,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export async function addScripts(projectPath, scriptsToAdd) {
|
|
94
|
-
return patchPackageJson(projectPath, {
|
|
95
|
-
scripts: scriptsToAdd,
|
|
96
|
-
});
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
function sortRecordEntries(record) {
|
|
5
|
+
if (!record) {
|
|
6
|
+
return record;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return Object.fromEntries(
|
|
10
|
+
Object.entries(record).sort(([leftName], [rightName]) => (
|
|
11
|
+
leftName.localeCompare(rightName)
|
|
12
|
+
)),
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function mergeRecordEntries(currentRecord, entriesToAdd) {
|
|
17
|
+
if (!entriesToAdd || Object.keys(entriesToAdd).length === 0) {
|
|
18
|
+
return currentRecord;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return sortRecordEntries({
|
|
22
|
+
...(currentRecord ?? {}),
|
|
23
|
+
...entriesToAdd,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizePackageJson(packageJson) {
|
|
28
|
+
packageJson.dependencies = sortRecordEntries(packageJson.dependencies);
|
|
29
|
+
packageJson.devDependencies = sortRecordEntries(packageJson.devDependencies);
|
|
30
|
+
packageJson.scripts = sortRecordEntries(packageJson.scripts);
|
|
31
|
+
|
|
32
|
+
return packageJson;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function readPackageJson(projectPath) {
|
|
36
|
+
const packageJsonPath = resolve(projectPath, 'package.json');
|
|
37
|
+
const content = await readFile(packageJsonPath, 'utf8');
|
|
38
|
+
|
|
39
|
+
return JSON.parse(content);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function writePackageJson(projectPath, packageJson) {
|
|
43
|
+
const packageJsonPath = resolve(projectPath, 'package.json');
|
|
44
|
+
|
|
45
|
+
await writeFile(
|
|
46
|
+
packageJsonPath,
|
|
47
|
+
`${JSON.stringify(normalizePackageJson(packageJson), null, 4)}\n`,
|
|
48
|
+
'utf8',
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function updatePackageJson(projectPath, updater) {
|
|
53
|
+
const packageJson = await readPackageJson(projectPath);
|
|
54
|
+
|
|
55
|
+
await updater(packageJson);
|
|
56
|
+
|
|
57
|
+
await writePackageJson(projectPath, packageJson);
|
|
58
|
+
|
|
59
|
+
return packageJson;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function patchPackageJson(projectPath, patch) {
|
|
63
|
+
return updatePackageJson(projectPath, (packageJson) => {
|
|
64
|
+
packageJson.dependencies = mergeRecordEntries(
|
|
65
|
+
packageJson.dependencies,
|
|
66
|
+
patch.dependencies,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
packageJson.devDependencies = mergeRecordEntries(
|
|
70
|
+
packageJson.devDependencies,
|
|
71
|
+
patch.devDependencies,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
packageJson.scripts = mergeRecordEntries(
|
|
75
|
+
packageJson.scripts,
|
|
76
|
+
patch.scripts,
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function addDependencies(projectPath, dependenciesToAdd) {
|
|
82
|
+
return patchPackageJson(projectPath, {
|
|
83
|
+
dependencies: dependenciesToAdd,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function addDevDependencies(projectPath, dependenciesToAdd) {
|
|
88
|
+
return patchPackageJson(projectPath, {
|
|
89
|
+
devDependencies: dependenciesToAdd,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function addScripts(projectPath, scriptsToAdd) {
|
|
94
|
+
return patchPackageJson(projectPath, {
|
|
95
|
+
scripts: scriptsToAdd,
|
|
96
|
+
});
|
|
97
97
|
}
|