@dhis2/create-app 5.3.0-alpha.2 → 5.3.0-alpha.4
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 +47 -61
- 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.4",
|
|
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,24 +84,14 @@ 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:
|
|
90
|
+
argv.packageManager ?? getPackageManager() ?? 'pnpm',
|
|
91
|
+
templateName: argv.template,
|
|
92
|
+
}
|
|
101
93
|
|
|
102
94
|
if (!useDefauls) {
|
|
103
|
-
const packageManager = await select({
|
|
104
|
-
message: 'Select a package manager',
|
|
105
|
-
default: 'pnpm',
|
|
106
|
-
choices: [
|
|
107
|
-
{ name: 'npm', value: 'npm' },
|
|
108
|
-
{ name: 'pnpm', value: 'pnpm' },
|
|
109
|
-
{ name: 'yarn 1 (legacy)', value: 'yarn' },
|
|
110
|
-
],
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
selectedOptions.packageManager = packageManager
|
|
114
|
-
|
|
115
95
|
const language = await select({
|
|
116
96
|
message: 'Select a language',
|
|
117
97
|
default: 'ts',
|
|
@@ -124,7 +104,7 @@ const command = {
|
|
|
124
104
|
selectedOptions.typeScript = language === 'ts'
|
|
125
105
|
|
|
126
106
|
const template = await select({
|
|
127
|
-
message: 'Select a
|
|
107
|
+
message: 'Select a template',
|
|
128
108
|
default: 'ts',
|
|
129
109
|
choices: [
|
|
130
110
|
{ name: 'Basic Template', value: 'basic' },
|
|
@@ -136,23 +116,15 @@ const command = {
|
|
|
136
116
|
})
|
|
137
117
|
|
|
138
118
|
selectedOptions.templateName = template
|
|
139
|
-
selectedOptions.template = getTemplateFile(template)
|
|
140
119
|
}
|
|
141
120
|
|
|
142
|
-
// let pkgManager = 'yarn'
|
|
143
|
-
// if (pnpm) {
|
|
144
|
-
// pkgManager = 'pnpm'
|
|
145
|
-
// } else if (npm) {
|
|
146
|
-
// pkgManager = 'npm'
|
|
147
|
-
// }
|
|
148
|
-
|
|
149
121
|
reporter.info(
|
|
150
122
|
`Initialising a new project using "${selectedOptions.packageManager}" as a package manager.`
|
|
151
123
|
)
|
|
152
124
|
|
|
153
|
-
if (selectedOptions.packageManager
|
|
125
|
+
if (selectedOptions.packageManager === 'yarn') {
|
|
154
126
|
reporter.warn(
|
|
155
|
-
'We recommend using "pnpm" as a package manager for new projects.
|
|
127
|
+
'We recommend using "pnpm" as a package manager for new projects. Yarn 1 will be deprecated in future versions of the CLI.'
|
|
156
128
|
)
|
|
157
129
|
}
|
|
158
130
|
// create the folder where the template will be generated
|
|
@@ -166,9 +138,26 @@ const command = {
|
|
|
166
138
|
process.exit(1)
|
|
167
139
|
}
|
|
168
140
|
|
|
169
|
-
reporter.info(
|
|
141
|
+
reporter.info(`${chalk.cyan('Selected options:')}`)
|
|
142
|
+
for (const [x, y] of Object.entries(selectedOptions)) {
|
|
143
|
+
reporter.info(` ${x}: ${y}`)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
// Running git clean on templates folder
|
|
148
|
+
// This is useful in local development if you have built the templates for testing
|
|
149
|
+
// and want to make sure to delete d2 and node_modules folders before copying the template
|
|
150
|
+
execSync(`git clean -X -f -- ${templates.templateRoot}`, {
|
|
151
|
+
stdio: 'ignore',
|
|
152
|
+
})
|
|
153
|
+
reporter.debug('Successfully ran git clean')
|
|
154
|
+
} catch (err) {
|
|
155
|
+
reporter.debug(err)
|
|
156
|
+
}
|
|
170
157
|
|
|
171
|
-
|
|
158
|
+
reporter.info('Copying template files')
|
|
159
|
+
const templateFiles = getTemplateFile(selectedOptions.templateName)
|
|
160
|
+
fs.copySync(templateFiles, cwd)
|
|
172
161
|
|
|
173
162
|
const paths = {
|
|
174
163
|
base: cwd,
|
|
@@ -235,6 +224,8 @@ const command = {
|
|
|
235
224
|
|
|
236
225
|
// copy correct lock file for npm/yarn
|
|
237
226
|
if (!pnpm) {
|
|
227
|
+
// ? copying yarn.lock or package-lock speeds installation a bit
|
|
228
|
+
// ? but we could also just run "yarn install" and generate the lock file
|
|
238
229
|
if (fs.existsSync(paths.pnpmLock)) {
|
|
239
230
|
fs.removeSync(paths.pnpmLock)
|
|
240
231
|
}
|
|
@@ -304,19 +295,6 @@ const command = {
|
|
|
304
295
|
|
|
305
296
|
reporter.info(`Running '${pkgManager} install'`)
|
|
306
297
|
|
|
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
298
|
await exec({
|
|
321
299
|
cmd: pkgManager,
|
|
322
300
|
args: ['install'],
|
|
@@ -324,7 +302,8 @@ const command = {
|
|
|
324
302
|
pipe: argv.debug,
|
|
325
303
|
})
|
|
326
304
|
|
|
327
|
-
|
|
305
|
+
// ToDo: setup the formatting on CLI project properly and avoid running it on scaffolding
|
|
306
|
+
reporter.debug(`Running '${pkgManager} format' (prettier)`)
|
|
328
307
|
await exec({
|
|
329
308
|
cmd: pkgManager,
|
|
330
309
|
args: npm ? ['run', 'format'] : ['format'],
|
|
@@ -332,7 +311,14 @@ const command = {
|
|
|
332
311
|
pipe: argv.debug,
|
|
333
312
|
})
|
|
334
313
|
|
|
335
|
-
reporter.info('Done!')
|
|
314
|
+
reporter.info(`${chalk.greenBright('Done!')}`)
|
|
315
|
+
|
|
316
|
+
const cdCmd = name != '.' ? `cd ${name} && ` : ''
|
|
317
|
+
reporter.print(
|
|
318
|
+
`Run ${chalk.bold(
|
|
319
|
+
`${cdCmd}${pkgManager} start`
|
|
320
|
+
)} to launch your new DHIS2 application`
|
|
321
|
+
)
|
|
336
322
|
|
|
337
323
|
return
|
|
338
324
|
},
|
|
@@ -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
|
+
}
|