@undp/create-app 0.2.0 → 0.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/README.md
CHANGED
|
@@ -42,13 +42,6 @@ You don’t need to install it globally — just use **npx**:
|
|
|
42
42
|
npx @undp/create-app my-project
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
or install it globally
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npm install -g @undp/create-app
|
|
49
|
-
create-undp-app my-project
|
|
50
|
-
```
|
|
51
|
-
|
|
52
45
|
---
|
|
53
46
|
|
|
54
47
|
## 📦 Getting started
|
|
@@ -12,8 +12,6 @@ function getLatestVersion(pkg) {
|
|
|
12
12
|
|
|
13
13
|
export function generatePackageJson(config) {
|
|
14
14
|
const designSystemVer = `^${getLatestVersion('@undp/design-system-react')}`
|
|
15
|
-
const dataVizVer = `^${getLatestVersion('@undp/data-viz')}`
|
|
16
|
-
const lucideReactVer = `^${getLatestVersion('lucide-react')}`
|
|
17
15
|
const dependencies = config.libraries.includes('peer') && config.libraries.includes('@undp/data-viz') ? {
|
|
18
16
|
"@undp/design-system-react": designSystemVer,
|
|
19
17
|
"react": "^19.2.0",
|
|
@@ -58,10 +56,12 @@ export function generatePackageJson(config) {
|
|
|
58
56
|
break;
|
|
59
57
|
}
|
|
60
58
|
if (config.libraries.includes('@undp/data-viz')) {
|
|
61
|
-
|
|
59
|
+
const dataVizVer = `^${getLatestVersion('@undp/data-viz')}`
|
|
60
|
+
dependencies['@undp/data-viz'] = dataVizVer;
|
|
62
61
|
}
|
|
63
62
|
if (config.libraries.includes('lucide-react')) {
|
|
64
|
-
|
|
63
|
+
const lucideReactVer = `^${getLatestVersion('lucide-react')}`
|
|
64
|
+
dependencies['lucide-react'] = lucideReactVer;
|
|
65
65
|
}
|
|
66
66
|
const devDependencies = config.framework !== 'next-basic' && config.framework !== 'next-auth' ? {
|
|
67
67
|
"@eslint/config-array": "^0.21.1",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function generateStaticWebAppConfig() {
|
|
2
|
+
return `{
|
|
3
|
+
"globalHeaders": {
|
|
4
|
+
"Access-Control-Allow-Origin": "*",
|
|
5
|
+
"Access-Control-Allow-Methods": "GET, OPTIONS"
|
|
6
|
+
},
|
|
7
|
+
"routes": [
|
|
8
|
+
{
|
|
9
|
+
"route": "/react-*.js",
|
|
10
|
+
"headers": {
|
|
11
|
+
"Access-Control-Allow-Origin": "*",
|
|
12
|
+
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
13
|
+
"Cache-Control": "public, max-age=31536000, immutable"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"route": "/undp-*.js",
|
|
18
|
+
"headers": {
|
|
19
|
+
"Access-Control-Allow-Origin": "*",
|
|
20
|
+
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
21
|
+
"Cache-Control": "public, max-age=31536000, immutable"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"route": "/index.js",
|
|
26
|
+
"headers": {
|
|
27
|
+
"Access-Control-Allow-Origin": "*",
|
|
28
|
+
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
29
|
+
"Cache-Control": "no-cache"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"route": "/*",
|
|
34
|
+
"headers": {
|
|
35
|
+
"Access-Control-Allow-Origin": "*",
|
|
36
|
+
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
37
|
+
"Cache-Control": "no-cache"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"navigationFallback": {
|
|
42
|
+
"rewrite": "/index.html",
|
|
43
|
+
"exclude": ["/assets/*", "/*.js", "/*.css", "/*.png", "/*.jpg", "/*.svg"]
|
|
44
|
+
}
|
|
45
|
+
}`
|
|
46
|
+
}
|
|
47
|
+
|
package/bin/index.js
CHANGED
|
@@ -8,7 +8,12 @@ import { promptUser } from './promptUser.js';
|
|
|
8
8
|
import fs from 'fs';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
10
|
import { printSuccess, createFolders } from './utils/index.js';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
generatePackageJson,
|
|
13
|
+
generateViteConfig,
|
|
14
|
+
generateIndexHtml,
|
|
15
|
+
generateStaticWebAppConfig,
|
|
16
|
+
} from './generateFiles/index.js';
|
|
12
17
|
|
|
13
18
|
function copyFolder(source, destination) {
|
|
14
19
|
fs.cpSync(source, destination, { recursive: true, force: true });
|
|
@@ -58,6 +63,9 @@ async function main() {
|
|
|
58
63
|
if (config.framework.includes('vite')) {
|
|
59
64
|
fs.writeFileSync('vite.config.ts', generateViteConfig(config));
|
|
60
65
|
fs.writeFileSync('index.html', generateIndexHtml(config));
|
|
66
|
+
if (config.addStaticWebAppConfig) {
|
|
67
|
+
fs.writeFileSync('staticwebapp.config.json', generateStaticWebAppConfig());
|
|
68
|
+
}
|
|
61
69
|
}
|
|
62
70
|
fs.writeFileSync('package.json', JSON.stringify(generatePackageJson(config), null, 2));
|
|
63
71
|
|
package/package.json
CHANGED
package/bin/generateFiles.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import {
|
|
4
|
-
generatePackageJson,
|
|
5
|
-
generateReadme,
|
|
6
|
-
generateStyleCss,
|
|
7
|
-
copyTemplate,
|
|
8
|
-
generateNextLayout,
|
|
9
|
-
} from './generateFiles/index.js';
|
|
10
|
-
|
|
11
|
-
export function generateFiles(config) {
|
|
12
|
-
// Main files
|
|
13
|
-
let projectType = 'basic';
|
|
14
|
-
|
|
15
|
-
if (config.installRouter && config.installQuery) {
|
|
16
|
-
projectType = 'router+query';
|
|
17
|
-
} else if (config.installRouter) {
|
|
18
|
-
projectType = 'router';
|
|
19
|
-
} else if (config.installQuery) {
|
|
20
|
-
projectType = 'query';
|
|
21
|
-
} else {
|
|
22
|
-
projectType = 'basic';
|
|
23
|
-
}
|
|
24
|
-
copyTemplate('src/main.tsx', 'main.txt', ['templates', projectType]);
|
|
25
|
-
copyTemplate(
|
|
26
|
-
'src/App.tsx',
|
|
27
|
-
config.addPostCSSScripts && !config.installRouter ? 'AppWithContainer.txt' : 'App.txt',
|
|
28
|
-
['templates', projectType]
|
|
29
|
-
);
|
|
30
|
-
if (config.installRouter) {
|
|
31
|
-
copyTemplate('src/components/Header.tsx', 'Header.txt', ['templates', projectType, 'components']);
|
|
32
|
-
copyTemplate('src/components/Footer.tsx', 'Footer.txt', ['templates', projectType, 'components']);
|
|
33
|
-
if (config.installQuery) {
|
|
34
|
-
copyTemplate('src/integration/tanstack-query.tsx', 'tanstack-query.txt', ['templates', projectType, 'integration']);
|
|
35
|
-
copyTemplate('src/routes/queryDemo.tsx', 'queryDemo.txt', ['templates', projectType, 'routes']);
|
|
36
|
-
} else {
|
|
37
|
-
copyTemplate('src/routes/About.tsx', 'About.txt', ['templates', projectType, 'routes']);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
fs.writeFileSync('src/styles/style.css', generateStyleCss(config.installDataViz));
|
|
41
|
-
copyTemplate('src/styles/fonts.css', 'fonts.css', ['templates', 'css']);
|
|
42
|
-
copyTemplate('src/assets/undp-logo-blue.svg', 'icon.txt', ['templates', 'configFiles']);
|
|
43
|
-
copyTemplate('public/undp-logo-blue.svg', 'icon.txt', ['templates', 'configFiles']);
|
|
44
|
-
console.log(chalk.green(' ✓ Created core files and base styles.'));
|
|
45
|
-
|
|
46
|
-
// Config files
|
|
47
|
-
console.log(chalk.bold.yellow('\n⚙️ Creating configuration and tooling files...'));
|
|
48
|
-
copyTemplate('eslint.config.mjs', 'eslint.config.mjs', ['templates', 'configFiles']);
|
|
49
|
-
copyTemplate('.prettierrc', '.prettierrc', ['templates', 'configFiles']);
|
|
50
|
-
copyTemplate('vite.config.ts', config.addPostCSSScripts ? 'vite.config.ts.txt' : 'viteWithoutPostCss.config.ts.txt', ['templates', 'configFiles']);
|
|
51
|
-
fs.writeFileSync('src/vite-env.d.ts', `/// <reference types="vite/client" />`);
|
|
52
|
-
copyTemplate('tsconfig.json', 'tsconfig.json', ['templates', 'configFiles']);
|
|
53
|
-
copyTemplate('tsconfig.node.json', 'tsconfig.node.json', ['templates', 'configFiles']);
|
|
54
|
-
copyTemplate('tailwind.config.js', 'tailwind.config.js', ['templates', 'configFiles']);
|
|
55
|
-
if (config.addStaticWebAppConfig) {
|
|
56
|
-
copyTemplate('staticwebapp.config.json', 'staticwebapp.config.json', ['templates', 'configFiles']);
|
|
57
|
-
}
|
|
58
|
-
copyTemplate('.gitignore', '.gitignore', ['templates', 'configFiles']);
|
|
59
|
-
fs.writeFileSync('README.md', generateReadme(config));
|
|
60
|
-
console.log(chalk.green(' ✓ Created ESLint, Prettier, Vite, TypeScript, Tailwind, and other configs.'));
|
|
61
|
-
|
|
62
|
-
// Package.json
|
|
63
|
-
console.log(chalk.bold.yellow('\n📜 Creating package.json and scripts...'));
|
|
64
|
-
fs.writeFileSync('package.json', JSON.stringify(generatePackageJson(config), null, 2));
|
|
65
|
-
console.log(chalk.green(' ✓ Created package.json.'));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export function generateNextFiles(config) {
|
|
70
|
-
// Main files
|
|
71
|
-
copyTemplate('public/undp-logo-blue.svg', 'icon.txt', ['templates', 'configFiles']);
|
|
72
|
-
fs.writeFileSync('src/styles/style.css', generateStyleCss(config.installDataViz));
|
|
73
|
-
copyTemplate('src/styles/fonts.css', 'fonts.css', ['templates', 'css']);
|
|
74
|
-
fs.writeFileSync('src/app/layout.tsx', generateNextLayout(config.projectName));
|
|
75
|
-
copyTemplate('src/app/page.tsx', 'page.txt', ['templates', 'next']);
|
|
76
|
-
copyTemplate('src/app/head.tsx', 'head.txt', ['templates', 'next']);
|
|
77
|
-
copyTemplate('src/app/about/page.tsx', 'About.txt', ['templates', 'next', 'routes']);
|
|
78
|
-
copyTemplate('src/components/Header.tsx', 'Header.txt', ['templates', 'next', 'components']);
|
|
79
|
-
copyTemplate('src/components/Footer.tsx', 'Footer.txt', ['templates', 'next', 'components']);
|
|
80
|
-
console.log(chalk.green(' ✓ Created core files and base styles.'));
|
|
81
|
-
|
|
82
|
-
// Config files
|
|
83
|
-
console.log(chalk.bold.yellow('\n⚙️ Creating configuration and tooling files...'));
|
|
84
|
-
copyTemplate('.next/types/routes.d.ts', 'routes.d.ts.txt', ['templates', 'next']);
|
|
85
|
-
copyTemplate('.next/types/validator.ts', 'validator.ts.txt', ['templates', 'next']);
|
|
86
|
-
copyTemplate('eslint.config.mjs', 'eslint.config.mjs', ['templates', 'configFiles']);
|
|
87
|
-
copyTemplate('.prettierrc', '.prettierrc', ['templates', 'configFiles']);
|
|
88
|
-
copyTemplate('tsconfig.json', 'tsconfig.json', ['templates', 'configFiles']);
|
|
89
|
-
copyTemplate('tsconfig.node.json', 'tsconfig.node.json', ['templates', 'configFiles']);
|
|
90
|
-
copyTemplate('tailwind.config.js', 'tailwind.config.js', ['templates', 'configFiles']);
|
|
91
|
-
copyTemplate('.gitignore', '.gitignore', ['templates', 'configFiles']);
|
|
92
|
-
copyTemplate('next.config.ts', 'next.config.ts.txt', ['templates', 'next']);
|
|
93
|
-
copyTemplate('next-env.d.ts', 'next-env.d.ts.txt', ['templates', 'next']);
|
|
94
|
-
copyTemplate('postcss.config.mjs', 'postcss.config.mjs.txt', ['templates', 'next']);
|
|
95
|
-
if (config.addAuth) {
|
|
96
|
-
copyTemplate('.env.local', '.env.local', ['templates', 'configFiles']);
|
|
97
|
-
}
|
|
98
|
-
fs.writeFileSync('README.md', generateReadme(config));
|
|
99
|
-
console.log(chalk.green(' ✓ Created ESLint, Prettier, Next, TypeScript, Tailwind, and other configs.'));
|
|
100
|
-
|
|
101
|
-
// Package.json
|
|
102
|
-
console.log(chalk.bold.yellow('\n📜 Creating package.json and scripts...'));
|
|
103
|
-
fs.writeFileSync('package.json', JSON.stringify(generatePackageJson(config), null, 2));
|
|
104
|
-
console.log(chalk.green(' ✓ Created package.json.'));
|
|
105
|
-
}
|