@dhis2/create-app 5.3.0-alpha.2 → 5.3.0-alpha.3
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/package.json +1 -2
- package/src/index.js +46 -49
- package/src/utils/getPackageManager.js +15 -0
- package/templates/template-ts-dataelements/.prettierrc.mjs +10 -0
- package/templates/template-ts-dataelements/README.md +45 -0
- package/templates/template-ts-dataelements/d2.config.js +12 -0
- package/templates/template-ts-dataelements/eslint.config.mjs +13 -0
- package/templates/template-ts-dataelements/i18n/en.pot +42 -0
- package/templates/template-ts-dataelements/package.json +35 -0
- package/templates/template-ts-dataelements/pnpm-lock.yaml +12950 -0
- package/templates/template-ts-dataelements/pnpm-workspace.yaml +17 -0
- package/templates/template-ts-dataelements/src/App.module.css +22 -0
- package/templates/template-ts-dataelements/src/App.test.tsx +21 -0
- package/templates/template-ts-dataelements/src/App.tsx +95 -0
- package/templates/template-ts-dataelements/src/components/DataElementsList.module.css +9 -0
- package/templates/template-ts-dataelements/src/components/DataElementsList.tsx +132 -0
- package/templates/template-ts-dataelements/tsconfig.json +17 -0
- package/templates/template-ts-dataelements/types/global.d.ts +8 -0
- package/templates/template-ts-dataelements/types/modules.d.ts +4 -0
- package/templates/template-ts-dataelements/viteConfigExtensions.mts +15 -0
- package/templates/template-ts-dataelements-react-router/.prettierrc.mjs +10 -0
- package/templates/template-ts-dataelements-react-router/README.md +45 -0
- package/templates/template-ts-dataelements-react-router/d2.config.js +12 -0
- package/templates/template-ts-dataelements-react-router/eslint.config.mjs +13 -0
- package/templates/template-ts-dataelements-react-router/i18n/en.pot +39 -0
- package/templates/template-ts-dataelements-react-router/package.json +36 -0
- package/templates/template-ts-dataelements-react-router/pnpm-lock.yaml +12982 -0
- package/templates/template-ts-dataelements-react-router/pnpm-workspace.yaml +17 -0
- package/templates/template-ts-dataelements-react-router/src/App.module.css +61 -0
- package/templates/template-ts-dataelements-react-router/src/App.test.tsx +21 -0
- package/templates/template-ts-dataelements-react-router/src/App.tsx +94 -0
- package/templates/template-ts-dataelements-react-router/src/AppWrapper.tsx +31 -0
- package/templates/template-ts-dataelements-react-router/src/components/About.tsx +15 -0
- package/templates/template-ts-dataelements-react-router/src/components/AppMenu.tsx +31 -0
- package/templates/template-ts-dataelements-react-router/src/components/DataElementsList.module.css +9 -0
- package/templates/template-ts-dataelements-react-router/src/components/DataElementsList.tsx +132 -0
- package/templates/template-ts-dataelements-react-router/tsconfig.json +17 -0
- package/templates/template-ts-dataelements-react-router/types/global.d.ts +8 -0
- package/templates/template-ts-dataelements-react-router/types/modules.d.ts +4 -0
- package/templates/template-ts-dataelements-react-router/viteConfigExtensions.mts +15 -0
- package/templates/template-ts-dataelements-react-router.zip +0 -0
- package/templates/template-ts-dataelements.zip +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2/create-app",
|
|
3
|
-
"version": "5.3.0-alpha.
|
|
3
|
+
"version": "5.3.0-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@dhis2/cli-helpers-engine": "^3.2.2",
|
|
14
14
|
"@inquirer/prompts": "^7.8.4",
|
|
15
|
-
"decompress": "^4.2.1",
|
|
16
15
|
"fast-glob": "^3.3.3",
|
|
17
16
|
"fs-extra": "^11.3.3"
|
|
18
17
|
},
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
const { execSync } = require('child_process')
|
|
1
2
|
const path = require('path')
|
|
2
|
-
const { reporter, exec } = require('@dhis2/cli-helpers-engine')
|
|
3
|
+
const { reporter, exec, chalk } = require('@dhis2/cli-helpers-engine')
|
|
3
4
|
const { input, select } = require('@inquirer/prompts')
|
|
4
|
-
const decompress = require('decompress')
|
|
5
5
|
const fg = require('fast-glob')
|
|
6
6
|
const fs = require('fs-extra')
|
|
7
|
+
const { default: getPackageManager } = require('./utils/getPackageManager')
|
|
7
8
|
|
|
8
9
|
process.on('uncaughtException', (error) => {
|
|
9
10
|
if (error instanceof Error && error.name === 'ExitPromptError') {
|
|
@@ -15,14 +16,15 @@ process.on('uncaughtException', (error) => {
|
|
|
15
16
|
})
|
|
16
17
|
|
|
17
18
|
const templates = {
|
|
19
|
+
templateRoot: path.join(__dirname, '../templates'),
|
|
18
20
|
templateWithList: path.join(
|
|
19
21
|
__dirname,
|
|
20
|
-
'../templates/template-ts-dataelements
|
|
22
|
+
'../templates/template-ts-dataelements'
|
|
21
23
|
),
|
|
22
24
|
|
|
23
25
|
templateWithReactRouter: path.join(
|
|
24
26
|
__dirname,
|
|
25
|
-
'../templates/template-ts-dataelements-react-router
|
|
27
|
+
'../templates/template-ts-dataelements-react-router'
|
|
26
28
|
),
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -51,24 +53,17 @@ const commandHandler = {
|
|
|
51
53
|
packageManager: {
|
|
52
54
|
description: 'Package Manager',
|
|
53
55
|
type: 'string',
|
|
54
|
-
default: 'pnpm',
|
|
55
56
|
alias: ['package', 'packagemanager'],
|
|
56
57
|
},
|
|
57
58
|
},
|
|
58
59
|
}
|
|
60
|
+
|
|
59
61
|
const getTemplateFile = (templateName) => {
|
|
60
62
|
return templateName === 'react-router'
|
|
61
63
|
? templates.templateWithReactRouter
|
|
62
64
|
: templates.templateWithList
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
const defaultOptions = {
|
|
66
|
-
typeScript: true,
|
|
67
|
-
templateName: 'basic',
|
|
68
|
-
template: getTemplateFile('basic'),
|
|
69
|
-
packageManager: 'pnpm',
|
|
70
|
-
}
|
|
71
|
-
|
|
72
67
|
const command = {
|
|
73
68
|
command: '[app]',
|
|
74
69
|
builder: (yargs) => {
|
|
@@ -77,11 +72,6 @@ const command = {
|
|
|
77
72
|
handler: async (argv) => {
|
|
78
73
|
let name = argv._[0] || argv.name
|
|
79
74
|
|
|
80
|
-
const selectedOptions = {
|
|
81
|
-
...defaultOptions,
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
reporter.debug(`running "npm create @dhis2/app" (or npx) command"`)
|
|
85
75
|
const useDefauls = argv.yes
|
|
86
76
|
|
|
87
77
|
if (!name) {
|
|
@@ -94,10 +84,11 @@ const command = {
|
|
|
94
84
|
reporter.log(`name of project: ${name}`)
|
|
95
85
|
}
|
|
96
86
|
|
|
97
|
-
selectedOptions
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
const selectedOptions = {
|
|
88
|
+
typeScript: argv.typescript,
|
|
89
|
+
packageManager: argv.packageManager ?? getPackageManager(),
|
|
90
|
+
templateName: argv.template,
|
|
91
|
+
}
|
|
101
92
|
|
|
102
93
|
if (!useDefauls) {
|
|
103
94
|
const packageManager = await select({
|
|
@@ -124,7 +115,7 @@ const command = {
|
|
|
124
115
|
selectedOptions.typeScript = language === 'ts'
|
|
125
116
|
|
|
126
117
|
const template = await select({
|
|
127
|
-
message: 'Select a
|
|
118
|
+
message: 'Select a template',
|
|
128
119
|
default: 'ts',
|
|
129
120
|
choices: [
|
|
130
121
|
{ name: 'Basic Template', value: 'basic' },
|
|
@@ -136,23 +127,15 @@ const command = {
|
|
|
136
127
|
})
|
|
137
128
|
|
|
138
129
|
selectedOptions.templateName = template
|
|
139
|
-
selectedOptions.template = getTemplateFile(template)
|
|
140
130
|
}
|
|
141
131
|
|
|
142
|
-
// let pkgManager = 'yarn'
|
|
143
|
-
// if (pnpm) {
|
|
144
|
-
// pkgManager = 'pnpm'
|
|
145
|
-
// } else if (npm) {
|
|
146
|
-
// pkgManager = 'npm'
|
|
147
|
-
// }
|
|
148
|
-
|
|
149
132
|
reporter.info(
|
|
150
133
|
`Initialising a new project using "${selectedOptions.packageManager}" as a package manager.`
|
|
151
134
|
)
|
|
152
135
|
|
|
153
|
-
if (selectedOptions.packageManager
|
|
136
|
+
if (selectedOptions.packageManager === 'yarn') {
|
|
154
137
|
reporter.warn(
|
|
155
|
-
'We recommend using "pnpm" as a package manager for new projects.
|
|
138
|
+
'We recommend using "pnpm" as a package manager for new projects. Yarn 1 will be deprecated in future versions of the CLI.'
|
|
156
139
|
)
|
|
157
140
|
}
|
|
158
141
|
// create the folder where the template will be generated
|
|
@@ -166,9 +149,26 @@ const command = {
|
|
|
166
149
|
process.exit(1)
|
|
167
150
|
}
|
|
168
151
|
|
|
169
|
-
reporter.info(
|
|
152
|
+
reporter.info(`${chalk.cyan('Selected options:')}`)
|
|
153
|
+
for (const [x, y] of Object.entries(selectedOptions)) {
|
|
154
|
+
reporter.info(` ${x}: ${y}`)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
// Running git clean on templates folder
|
|
159
|
+
// This is useful in local development if you have built the templates for testing
|
|
160
|
+
// and want to make sure to delete d2 and node_modules folders before copying the template
|
|
161
|
+
execSync(`git clean -X -f -- ${templates.templateRoot}`, {
|
|
162
|
+
stdio: 'ignore',
|
|
163
|
+
})
|
|
164
|
+
reporter.debug('Successfully ran git clean')
|
|
165
|
+
} catch (err) {
|
|
166
|
+
reporter.debug(err)
|
|
167
|
+
}
|
|
170
168
|
|
|
171
|
-
|
|
169
|
+
reporter.info('Copying template files')
|
|
170
|
+
const templateFiles = getTemplateFile(selectedOptions.templateName)
|
|
171
|
+
fs.copySync(templateFiles, cwd)
|
|
172
172
|
|
|
173
173
|
const paths = {
|
|
174
174
|
base: cwd,
|
|
@@ -235,6 +235,8 @@ const command = {
|
|
|
235
235
|
|
|
236
236
|
// copy correct lock file for npm/yarn
|
|
237
237
|
if (!pnpm) {
|
|
238
|
+
// ? copying yarn.lock or package-lock speeds installation a bit
|
|
239
|
+
// ? but we could also just run "yarn install" and generate the lock file
|
|
238
240
|
if (fs.existsSync(paths.pnpmLock)) {
|
|
239
241
|
fs.removeSync(paths.pnpmLock)
|
|
240
242
|
}
|
|
@@ -304,19 +306,6 @@ const command = {
|
|
|
304
306
|
|
|
305
307
|
reporter.info(`Running '${pkgManager} install'`)
|
|
306
308
|
|
|
307
|
-
reporter.debug(`Upgrading @dhis2 dependencies to latest`)
|
|
308
|
-
await exec({
|
|
309
|
-
cmd: pkgManager,
|
|
310
|
-
args: [
|
|
311
|
-
npm ? 'install --save' : 'upgrade',
|
|
312
|
-
'@dhis2/app-runtime@latest',
|
|
313
|
-
'@dhis2/cli-app-scripts@latest',
|
|
314
|
-
'@dhis2/ui@latest',
|
|
315
|
-
],
|
|
316
|
-
cwd: paths.base,
|
|
317
|
-
pipe: argv.debug,
|
|
318
|
-
})
|
|
319
|
-
|
|
320
309
|
await exec({
|
|
321
310
|
cmd: pkgManager,
|
|
322
311
|
args: ['install'],
|
|
@@ -324,7 +313,8 @@ const command = {
|
|
|
324
313
|
pipe: argv.debug,
|
|
325
314
|
})
|
|
326
315
|
|
|
327
|
-
|
|
316
|
+
// ToDo: setup the formatting on CLI project properly and avoid running it on scaffolding
|
|
317
|
+
reporter.debug(`Running '${pkgManager} format' (prettier)`)
|
|
328
318
|
await exec({
|
|
329
319
|
cmd: pkgManager,
|
|
330
320
|
args: npm ? ['run', 'format'] : ['format'],
|
|
@@ -332,7 +322,14 @@ const command = {
|
|
|
332
322
|
pipe: argv.debug,
|
|
333
323
|
})
|
|
334
324
|
|
|
335
|
-
reporter.info('Done!')
|
|
325
|
+
reporter.info(`${chalk.greenBright('Done!')}`)
|
|
326
|
+
|
|
327
|
+
const cdCmd = name != '.' ? `cd ${name} && ` : ''
|
|
328
|
+
reporter.print(
|
|
329
|
+
`Run ${chalk.bold(
|
|
330
|
+
`${cdCmd}${pkgManager} start`
|
|
331
|
+
)} to launch your new DHIS2 application`
|
|
332
|
+
)
|
|
336
333
|
|
|
337
334
|
return
|
|
338
335
|
},
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const getPackageManager = () => {
|
|
2
|
+
const userAgent = process.env.npm_config_user_agent || ''
|
|
3
|
+
|
|
4
|
+
if (userAgent.startsWith('yarn')) {
|
|
5
|
+
return 'yarn'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (userAgent.startsWith('npm')) {
|
|
9
|
+
return 'npm'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return 'pnpm'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default getPackageManager
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
This project was bootstrapped with [DHIS2 Application Platform](https://github.com/dhis2/app-platform).
|
|
2
|
+
|
|
3
|
+
## Available Scripts
|
|
4
|
+
|
|
5
|
+
In the project directory, you can run:
|
|
6
|
+
|
|
7
|
+
### `yarn start`
|
|
8
|
+
|
|
9
|
+
Runs the app in the development mode.<br />
|
|
10
|
+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
|
11
|
+
|
|
12
|
+
The page will reload if you make edits.<br />
|
|
13
|
+
You will also see any lint errors in the console.
|
|
14
|
+
|
|
15
|
+
### `yarn test`
|
|
16
|
+
|
|
17
|
+
Launches the test runner and runs all available tests found in `/src`.<br />
|
|
18
|
+
|
|
19
|
+
See the section about [running tests](https://platform.dhis2.nu/#/scripts/test) for more information.
|
|
20
|
+
|
|
21
|
+
### `yarn build`
|
|
22
|
+
|
|
23
|
+
Builds the app for production to the `build` folder.<br />
|
|
24
|
+
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
25
|
+
|
|
26
|
+
The build is minified and the filenames include the hashes.<br />
|
|
27
|
+
A deployable `.zip` file can be found in `build/bundle`!
|
|
28
|
+
|
|
29
|
+
See the section about [building](https://platform.dhis2.nu/#/scripts/build) for more information.
|
|
30
|
+
|
|
31
|
+
### `yarn deploy`
|
|
32
|
+
|
|
33
|
+
Deploys the built app in the `build` folder to a running DHIS2 instance.<br />
|
|
34
|
+
This command will prompt you to enter a server URL as well as the username and password of a DHIS2 user with the App Management authority.<br/>
|
|
35
|
+
You must run `yarn build` before running `yarn deploy`.<br />
|
|
36
|
+
|
|
37
|
+
See the section about [deploying](https://platform.dhis2.nu/#/scripts/deploy) for more information.
|
|
38
|
+
|
|
39
|
+
## Learn More
|
|
40
|
+
|
|
41
|
+
You can learn more about the platform in the [DHIS2 Application Platform Documentation](https://platform.dhis2.nu/).
|
|
42
|
+
|
|
43
|
+
You can learn more about the runtime in the [DHIS2 Application Runtime Documentation](https://runtime.dhis2.nu/).
|
|
44
|
+
|
|
45
|
+
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import config from '@dhis2/config-eslint'
|
|
2
|
+
import { defineConfig } from 'eslint/config'
|
|
3
|
+
import { includeIgnoreFile } from '@eslint/compat'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
|
|
6
|
+
const gitignorePath = fileURLToPath(new URL('.gitignore', import.meta.url))
|
|
7
|
+
|
|
8
|
+
export default defineConfig([
|
|
9
|
+
includeIgnoreFile(gitignorePath, 'Imported .gitignore patterns'),
|
|
10
|
+
{
|
|
11
|
+
extends: [config],
|
|
12
|
+
},
|
|
13
|
+
])
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: i18next-conv\n"
|
|
4
|
+
"MIME-Version: 1.0\n"
|
|
5
|
+
"Content-Type: text/plain; charset=utf-8\n"
|
|
6
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
7
|
+
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
|
|
8
|
+
"POT-Creation-Date: 2026-01-03T10:11:58.219Z\n"
|
|
9
|
+
"PO-Revision-Date: 2026-01-03T10:11:58.220Z\n"
|
|
10
|
+
|
|
11
|
+
msgid "ERROR"
|
|
12
|
+
msgstr "ERROR"
|
|
13
|
+
|
|
14
|
+
msgid "Loading..."
|
|
15
|
+
msgstr "Loading..."
|
|
16
|
+
|
|
17
|
+
msgid "Hello {{name}}"
|
|
18
|
+
msgstr "Hello {{name}}"
|
|
19
|
+
|
|
20
|
+
msgid "Welcome to DHIS2 with TypeScript!"
|
|
21
|
+
msgstr "Welcome to DHIS2 with TypeScript!"
|
|
22
|
+
|
|
23
|
+
msgid "Error"
|
|
24
|
+
msgstr "Error"
|
|
25
|
+
|
|
26
|
+
msgid "Error loading the data elements"
|
|
27
|
+
msgstr "Error loading the data elements"
|
|
28
|
+
|
|
29
|
+
msgid "ID"
|
|
30
|
+
msgstr "ID"
|
|
31
|
+
|
|
32
|
+
msgid "Name"
|
|
33
|
+
msgstr "Name"
|
|
34
|
+
|
|
35
|
+
msgid "Domain"
|
|
36
|
+
msgstr "Domain"
|
|
37
|
+
|
|
38
|
+
msgid "Value Type"
|
|
39
|
+
msgstr "Value Type"
|
|
40
|
+
|
|
41
|
+
msgid "Created by"
|
|
42
|
+
msgstr "Created by"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{template-name}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "BSD-3-Clause",
|
|
6
|
+
"private": true,
|
|
7
|
+
"packageManager": "pnpm@10.13.1",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "d2-app-scripts build",
|
|
10
|
+
"start": "d2-app-scripts start",
|
|
11
|
+
"test": "d2-app-scripts test",
|
|
12
|
+
"deploy": "d2-app-scripts deploy",
|
|
13
|
+
"lint": "eslint && prettier -c .",
|
|
14
|
+
"format": "prettier . -w"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@dhis2/app-runtime": "^3.15.1",
|
|
18
|
+
"@dhis2/ui": "^10.11.0",
|
|
19
|
+
"react": "^18.3.1",
|
|
20
|
+
"react-dom": "^18.3.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@dhis2/cli-app-scripts": "12.8.0-alpha.3",
|
|
24
|
+
"@dhis2/config-eslint": "^0.2.2",
|
|
25
|
+
"@dhis2/config-prettier": "^0.2.2",
|
|
26
|
+
"@eslint/compat": "^2.0.0",
|
|
27
|
+
"@types/jest": "^30.0.0",
|
|
28
|
+
"@types/react": "^19.2.7",
|
|
29
|
+
"@types/react-dom": "^19.2.3",
|
|
30
|
+
"eslint": "^9.39.2",
|
|
31
|
+
"prettier": "^3.7.4",
|
|
32
|
+
"typescript": "^5.9.3",
|
|
33
|
+
"vite": "^7.3.0"
|
|
34
|
+
}
|
|
35
|
+
}
|