@undp/create-app 0.4.0 → 0.6.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/bin/generateFiles/generatePackageJson.js +149 -140
- package/package.json +1 -1
|
@@ -1,148 +1,157 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
3
|
|
|
4
4
|
function getLatestVersion(pkg) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
try {
|
|
6
|
+
return execSync(`npm show ${pkg} version`).toString().trim();
|
|
7
|
+
} catch {
|
|
8
|
+
return "latest";
|
|
9
|
+
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function generatePackageJson(config) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
13
|
+
console.log(chalk.gray(` Fetching latest version for packages...`));
|
|
14
|
+
const designSystemVer = `^${getLatestVersion("@undp/design-system-react")}`;
|
|
15
|
+
const typeScriptVer = `^${getLatestVersion("typescript")}`;
|
|
16
|
+
const zustandVer = `^${getLatestVersion("zustand")}`;
|
|
17
|
+
const tailwindcssVer = `^${getLatestVersion("tailwindcss")}`;
|
|
18
|
+
const twAnimateCssVer = `^${getLatestVersion("tw-animate-css")}`;
|
|
19
|
+
const dependenciesTemp =
|
|
20
|
+
config.libraries.includes("peer") &&
|
|
21
|
+
config.libraries.includes("@undp/data-viz")
|
|
22
|
+
? {
|
|
23
|
+
"@undp/design-system-react": designSystemVer,
|
|
24
|
+
"@dnd-kit/core": "^6.3.1",
|
|
25
|
+
"@dnd-kit/modifiers": "^9.0.0",
|
|
26
|
+
ajv: "^8.17.1",
|
|
27
|
+
"dom-to-svg": "^0.12.2",
|
|
28
|
+
"file-saver": "^2.0.5",
|
|
29
|
+
handlebars: "^4.7.8",
|
|
30
|
+
"maplibre-gl": "^5.16.0",
|
|
31
|
+
marked: "^18.0.9",
|
|
32
|
+
"math-expression-evaluator": "^2.0.7",
|
|
33
|
+
pmtiles: "^4.3.0",
|
|
34
|
+
react: "^19.2.3",
|
|
35
|
+
"react-dom": "^19.2.3",
|
|
36
|
+
"react-globe.gl": "^2.37.0",
|
|
37
|
+
three: "^0.182.0",
|
|
38
|
+
"tw-animate-css": twAnimateCssVer,
|
|
39
|
+
zustand: zustandVer,
|
|
40
|
+
}
|
|
41
|
+
: {
|
|
42
|
+
"@undp/design-system-react": designSystemVer,
|
|
43
|
+
react: "^19.2.3",
|
|
44
|
+
"react-dom": "^19.2.3",
|
|
45
|
+
"tw-animate-css": twAnimateCssVer,
|
|
46
|
+
zustand: zustandVer,
|
|
47
|
+
};
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
const dependencies =
|
|
50
|
+
config.language && !config.framework.includes("next")
|
|
51
|
+
? {
|
|
52
|
+
...dependenciesTemp,
|
|
53
|
+
i18next: "^26.0.8",
|
|
54
|
+
"i18next-browser-languagedetector": "^8.2.1",
|
|
55
|
+
"react-i18next": "^17.0.6",
|
|
56
|
+
}
|
|
57
|
+
: { ...dependenciesTemp };
|
|
46
58
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
111
|
-
const sortedDevDependencies = Object.fromEntries(
|
|
112
|
-
Object.entries(devDependencies).sort(([a], [b]) => a.localeCompare(b))
|
|
113
|
-
);
|
|
59
|
+
switch (config.framework) {
|
|
60
|
+
case "vite-router":
|
|
61
|
+
dependencies["@tanstack/react-router"] = "^1.141.1";
|
|
62
|
+
break;
|
|
63
|
+
case "next-basic":
|
|
64
|
+
dependencies["next"] = "16.0.10";
|
|
65
|
+
break;
|
|
66
|
+
case "next-auth":
|
|
67
|
+
dependencies["better-auth"] = "^1.3.34";
|
|
68
|
+
dependencies["next"] = "16.0.10";
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (config.query) {
|
|
74
|
+
dependencies["@tanstack/react-query"] = "^5.90.12";
|
|
75
|
+
}
|
|
76
|
+
if (config.libraries.includes("@undp/data-viz")) {
|
|
77
|
+
const dataVizVer = `^${getLatestVersion("@undp/data-viz")}`;
|
|
78
|
+
dependencies["@undp/data-viz"] = dataVizVer;
|
|
79
|
+
}
|
|
80
|
+
if (config.libraries.includes("lucide-react")) {
|
|
81
|
+
const lucideReactVer = `^${getLatestVersion("lucide-react")}`;
|
|
82
|
+
dependencies["lucide-react"] = lucideReactVer;
|
|
83
|
+
}
|
|
84
|
+
const sortedDependencies = Object.fromEntries(
|
|
85
|
+
Object.entries(dependencies).sort(([a], [b]) => a.localeCompare(b)),
|
|
86
|
+
);
|
|
87
|
+
const devDependencies = config.framework.includes("vite")
|
|
88
|
+
? {
|
|
89
|
+
"@biomejs/biome": "^2.4.12",
|
|
90
|
+
"@tailwindcss/postcss": "^4.1.17",
|
|
91
|
+
"@tailwindcss/vite": "^4.3.0",
|
|
92
|
+
"@types/node": "^24.10.0",
|
|
93
|
+
"@types/react": "^19.2.7",
|
|
94
|
+
"@types/react-dom": "^19.2.3",
|
|
95
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
96
|
+
autoprefixer: "^10.4.21",
|
|
97
|
+
postcss: "^8.5.6",
|
|
98
|
+
"postcss-nested": "^7.0.2",
|
|
99
|
+
rimraf: "^6.1.0",
|
|
100
|
+
"rollup-plugin-visualizer": "^6.0.5",
|
|
101
|
+
tailwindcss: tailwindcssVer,
|
|
102
|
+
typescript: typeScriptVer,
|
|
103
|
+
vite: "^8.0.13",
|
|
104
|
+
"vite-plugin-static-copy": "^4.1.0",
|
|
105
|
+
}
|
|
106
|
+
: {
|
|
107
|
+
"@biomejs/biome": "^2.4.12",
|
|
108
|
+
"@tailwindcss/postcss": "^4.1.17",
|
|
109
|
+
"@types/node": "^24.10.0",
|
|
110
|
+
"@types/react": "^19.2.7",
|
|
111
|
+
"@types/react-dom": "^19.2.3",
|
|
112
|
+
postcss: "^8.5.6",
|
|
113
|
+
"postcss-nested": "^7.0.2",
|
|
114
|
+
rimraf: "^6.1.0",
|
|
115
|
+
"rollup-plugin-visualizer": "^6.0.5",
|
|
116
|
+
tailwindcss: tailwindcssVer,
|
|
117
|
+
typescript: typeScriptVer,
|
|
118
|
+
};
|
|
119
|
+
const sortedDevDependencies = Object.fromEntries(
|
|
120
|
+
Object.entries(devDependencies).sort(([a], [b]) => a.localeCompare(b)),
|
|
121
|
+
);
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
123
|
+
const packageJson = {
|
|
124
|
+
name: config.projectName,
|
|
125
|
+
private: true,
|
|
126
|
+
version: "0.0.0",
|
|
127
|
+
type: "module",
|
|
128
|
+
keywords: [],
|
|
129
|
+
author: "",
|
|
130
|
+
sideEffects: ["*.css"],
|
|
131
|
+
scripts: config.framework.includes("next")
|
|
132
|
+
? {
|
|
133
|
+
dev: "next dev",
|
|
134
|
+
build: "next build",
|
|
135
|
+
start: "next start",
|
|
136
|
+
clean:
|
|
137
|
+
"rimraf node_modules && rimraf .next && rimraf package-lock.json",
|
|
138
|
+
check: "biome check .",
|
|
139
|
+
"check:fix": "biome check --write .",
|
|
140
|
+
"check:unsafe": "biome check --write --unsafe .",
|
|
141
|
+
}
|
|
142
|
+
: {
|
|
143
|
+
dev: "vite",
|
|
144
|
+
build: "tsc && vite build",
|
|
145
|
+
preview: "vite preview",
|
|
146
|
+
clean:
|
|
147
|
+
"rimraf node_modules && rimraf dist && rimraf package-lock.json",
|
|
148
|
+
"install:build": "npm install && tsc && vite build",
|
|
149
|
+
check: "biome check .",
|
|
150
|
+
"check:fix": "biome check --write .",
|
|
151
|
+
"check:unsafe": "biome check --write --unsafe .",
|
|
152
|
+
},
|
|
153
|
+
dependencies: sortedDependencies,
|
|
154
|
+
devDependencies: sortedDevDependencies,
|
|
155
|
+
};
|
|
156
|
+
return packageJson;
|
|
157
|
+
}
|