@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.
Files changed (42) hide show
  1. package/package.json +1 -2
  2. package/src/index.js +46 -49
  3. package/src/utils/getPackageManager.js +15 -0
  4. package/templates/template-ts-dataelements/.prettierrc.mjs +10 -0
  5. package/templates/template-ts-dataelements/README.md +45 -0
  6. package/templates/template-ts-dataelements/d2.config.js +12 -0
  7. package/templates/template-ts-dataelements/eslint.config.mjs +13 -0
  8. package/templates/template-ts-dataelements/i18n/en.pot +42 -0
  9. package/templates/template-ts-dataelements/package.json +35 -0
  10. package/templates/template-ts-dataelements/pnpm-lock.yaml +12950 -0
  11. package/templates/template-ts-dataelements/pnpm-workspace.yaml +17 -0
  12. package/templates/template-ts-dataelements/src/App.module.css +22 -0
  13. package/templates/template-ts-dataelements/src/App.test.tsx +21 -0
  14. package/templates/template-ts-dataelements/src/App.tsx +95 -0
  15. package/templates/template-ts-dataelements/src/components/DataElementsList.module.css +9 -0
  16. package/templates/template-ts-dataelements/src/components/DataElementsList.tsx +132 -0
  17. package/templates/template-ts-dataelements/tsconfig.json +17 -0
  18. package/templates/template-ts-dataelements/types/global.d.ts +8 -0
  19. package/templates/template-ts-dataelements/types/modules.d.ts +4 -0
  20. package/templates/template-ts-dataelements/viteConfigExtensions.mts +15 -0
  21. package/templates/template-ts-dataelements-react-router/.prettierrc.mjs +10 -0
  22. package/templates/template-ts-dataelements-react-router/README.md +45 -0
  23. package/templates/template-ts-dataelements-react-router/d2.config.js +12 -0
  24. package/templates/template-ts-dataelements-react-router/eslint.config.mjs +13 -0
  25. package/templates/template-ts-dataelements-react-router/i18n/en.pot +39 -0
  26. package/templates/template-ts-dataelements-react-router/package.json +36 -0
  27. package/templates/template-ts-dataelements-react-router/pnpm-lock.yaml +12982 -0
  28. package/templates/template-ts-dataelements-react-router/pnpm-workspace.yaml +17 -0
  29. package/templates/template-ts-dataelements-react-router/src/App.module.css +61 -0
  30. package/templates/template-ts-dataelements-react-router/src/App.test.tsx +21 -0
  31. package/templates/template-ts-dataelements-react-router/src/App.tsx +94 -0
  32. package/templates/template-ts-dataelements-react-router/src/AppWrapper.tsx +31 -0
  33. package/templates/template-ts-dataelements-react-router/src/components/About.tsx +15 -0
  34. package/templates/template-ts-dataelements-react-router/src/components/AppMenu.tsx +31 -0
  35. package/templates/template-ts-dataelements-react-router/src/components/DataElementsList.module.css +9 -0
  36. package/templates/template-ts-dataelements-react-router/src/components/DataElementsList.tsx +132 -0
  37. package/templates/template-ts-dataelements-react-router/tsconfig.json +17 -0
  38. package/templates/template-ts-dataelements-react-router/types/global.d.ts +8 -0
  39. package/templates/template-ts-dataelements-react-router/types/modules.d.ts +4 -0
  40. package/templates/template-ts-dataelements-react-router/viteConfigExtensions.mts +15 -0
  41. package/templates/template-ts-dataelements-react-router.zip +0 -0
  42. package/templates/template-ts-dataelements.zip +0 -0
@@ -0,0 +1,17 @@
1
+ # These hoists are needed for @dhis2/app-shell since it uses directly some libraries that were hoisted by yarn 1
2
+ # This is a better alternative than pnpm's shamefullyHoist https://pnpm.io/settings#shamefullyhoist until we update the way that @dhis2/app-shell works
3
+ publicHoistPattern:
4
+ - '@dhis2/ui'
5
+ - 'typeface-roboto'
6
+ - '@dhis2/app-adapter'
7
+ - 'prop-types'
8
+ - '@dhis2/d2-i18n'
9
+ - 'post-robot'
10
+ - 'styled-jsx'
11
+ - '@dhis2/app-adapter'
12
+ - '@dhis2/pwa'
13
+
14
+ onlyBuiltDependencies:
15
+ - '@dhis2/cli-helpers-engine'
16
+ - core-js-pure
17
+ - esbuild
@@ -0,0 +1,22 @@
1
+ .container {
2
+ width: 100%;
3
+ height: 100%;
4
+ display: flex;
5
+ flex-direction: column;
6
+ font-size: 1rem;
7
+ max-width: 1020px;
8
+ margin: 0px auto;
9
+ padding-top: 8px;
10
+ }
11
+
12
+ .noticeContainer {
13
+ max-width: 800px;
14
+ margin: 16px 0;
15
+ align-self: center;
16
+ }
17
+
18
+ :global(h2),
19
+ :global(h3) {
20
+ margin: 8px;
21
+ margin-inline-start: 0;
22
+ }
@@ -0,0 +1,21 @@
1
+ import { CustomDataProvider } from '@dhis2/app-runtime'
2
+ import React from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import App from './App'
5
+
6
+ it('renders without crashing', () => {
7
+ const container = document.createElement('div')
8
+
9
+ const data = {
10
+ resource: 'test',
11
+ }
12
+
13
+ const root = createRoot(container)
14
+ root.render(
15
+ <CustomDataProvider data={data}>
16
+ <App />
17
+ </CustomDataProvider>
18
+ )
19
+
20
+ root.unmount()
21
+ })
@@ -0,0 +1,95 @@
1
+ import { useDataQuery } from '@dhis2/app-runtime'
2
+ import i18n from '@dhis2/d2-i18n'
3
+ import { NoticeBox } from '@dhis2/ui'
4
+ import React, { FC } from 'react'
5
+ import classes from '@/App.module.css'
6
+ import DataElementsList from '@/components/DataElementsList'
7
+
8
+ interface QueryResults {
9
+ me: {
10
+ name: string
11
+ }
12
+ }
13
+
14
+ const query = {
15
+ me: {
16
+ resource: 'me',
17
+ },
18
+ }
19
+
20
+ const MyApp: FC = () => {
21
+ const { error, loading, data } = useDataQuery<QueryResults>(query)
22
+
23
+ if (error) {
24
+ return <span>{i18n.t('ERROR')}</span>
25
+ }
26
+
27
+ if (loading) {
28
+ return <span>{i18n.t('Loading...')}</span>
29
+ }
30
+
31
+ return (
32
+ <div className={classes.container}>
33
+ <h2>{i18n.t('Hello {{name}}', { name: data?.me?.name })}</h2>
34
+ <h3>{i18n.t('Welcome to DHIS2 with TypeScript!')}</h3>
35
+ <div className={classes.noticeContainer}>
36
+ <NoticeBox title="DHIS2 Web application">
37
+ This application was scaffolded using DHIS2 app platform
38
+ (with <code>npm create @dhis2/app</code>).
39
+ <br />
40
+ For more information, you can check the DHIS2 documentation:
41
+ <ul>
42
+ <li>
43
+ <a
44
+ target="_blank"
45
+ href="https://developers.dhis2.org/docs/guides"
46
+ rel="noreferrer"
47
+ >
48
+ Web development guides
49
+ </a>
50
+ </li>
51
+ <li>
52
+ <a
53
+ target="_blank"
54
+ href="https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/metadata.html"
55
+ rel="noreferrer"
56
+ >
57
+ Documentation for the API{' '}
58
+ </a>
59
+ </li>
60
+ <li>
61
+ <a
62
+ target="_blank"
63
+ href="https://developers.dhis2.org/docs/tutorials/app-runtime-query/"
64
+ rel="noreferrer"
65
+ >
66
+ AppRuntime and useDataQuery hook
67
+ </a>
68
+ </li>
69
+ <li>
70
+ <a
71
+ target="_blank"
72
+ href="https://developers.dhis2.org/docs/ui/webcomponents"
73
+ rel="noreferrer"
74
+ >
75
+ UI Library
76
+ </a>
77
+ </li>
78
+ <li>
79
+ <a
80
+ target="_blank"
81
+ href="https://developers.dhis2.org/demo/"
82
+ rel="noreferrer"
83
+ >
84
+ UI library demo
85
+ </a>
86
+ </li>
87
+ </ul>
88
+ </NoticeBox>
89
+ </div>
90
+ <DataElementsList />
91
+ </div>
92
+ )
93
+ }
94
+
95
+ export default MyApp
@@ -0,0 +1,9 @@
1
+ .tableContainer {
2
+ max-width: 168px;
3
+ }
4
+
5
+ @media (min-width: 768px) {
6
+ .tableContainer {
7
+ max-width: 90%;
8
+ }
9
+ }
@@ -0,0 +1,132 @@
1
+ import { useDataQuery } from '@dhis2/app-runtime'
2
+ import i18n from '@dhis2/d2-i18n'
3
+ import {
4
+ Center,
5
+ CircularLoader,
6
+ DataTable,
7
+ DataTableCell,
8
+ DataTableColumnHeader,
9
+ DataTableRow,
10
+ NoticeBox,
11
+ TableBody,
12
+ TableHead,
13
+ } from '@dhis2/ui'
14
+ import * as React from 'react'
15
+ import classes from './DataElementsList.module.css'
16
+ interface QueryResults {
17
+ dataElements: Array<{
18
+ id: string
19
+ name: string
20
+ displayName: string
21
+ domainType: string
22
+ valueType: string
23
+ createdBy: {
24
+ id: string
25
+ name: string
26
+ }
27
+ }>
28
+ }
29
+
30
+ /**
31
+ * Documentation for the API: https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/metadata.html
32
+ * Documentation for useDataQuery hook: https://developers.dhis2.org/docs/tutorials/app-runtime-query/
33
+ * UI Library: https://developers.dhis2.org/docs/ui/webcomponents
34
+ */
35
+ const PAGE_SIZE = 25
36
+ const query = {
37
+ dataElements: {
38
+ resource: 'dataElements',
39
+ params: {
40
+ pageSize: PAGE_SIZE,
41
+ fields: [
42
+ 'id,name,displayName,domainType,valueType,categoryCombo[id,name],createdBy',
43
+ ],
44
+ order: 'created:desc',
45
+ },
46
+ },
47
+ }
48
+ const DataElementsList = () => {
49
+ const { error, loading, data } = useDataQuery<{
50
+ dataElements: QueryResults
51
+ }>(query)
52
+
53
+ if (error) {
54
+ return (
55
+ <NoticeBox error title={i18n.t('Error')}>
56
+ {i18n.t('Error loading the data elements')}
57
+ </NoticeBox>
58
+ )
59
+ }
60
+
61
+ return (
62
+ <div>
63
+ <h2>{i18n.t('Last {{n}} Data Elements:', { n: PAGE_SIZE })}</h2>
64
+ <div className={classes.tableContainer}>
65
+ <DataTable>
66
+ <TableHead>
67
+ <DataTableRow>
68
+ <DataTableColumnHeader large>
69
+ {i18n.t('ID')}
70
+ </DataTableColumnHeader>
71
+ <DataTableColumnHeader large>
72
+ {i18n.t('Name')}
73
+ </DataTableColumnHeader>
74
+ <DataTableColumnHeader large>
75
+ {i18n.t('Domain')}
76
+ </DataTableColumnHeader>
77
+ <DataTableColumnHeader
78
+ width="180px"
79
+ align="center"
80
+ large
81
+ >
82
+ {i18n.t('Value Type')}
83
+ </DataTableColumnHeader>
84
+ <DataTableColumnHeader large>
85
+ {i18n.t('Created by')}{' '}
86
+ </DataTableColumnHeader>
87
+ </DataTableRow>
88
+ </TableHead>
89
+ <TableBody>
90
+ {loading && (
91
+ <DataTableRow>
92
+ <DataTableCell colSpan="100%">
93
+ <Center>
94
+ <CircularLoader large />
95
+ </Center>
96
+ </DataTableCell>
97
+ </DataTableRow>
98
+ )}
99
+ {data?.dataElements?.dataElements?.map(
100
+ (dataElement) => {
101
+ return (
102
+ <DataTableRow key={dataElement.id}>
103
+ <DataTableCell large>
104
+ {dataElement.id}
105
+ </DataTableCell>
106
+ <DataTableCell large>
107
+ {dataElement.displayName}
108
+ </DataTableCell>
109
+ <DataTableCell large>
110
+ {dataElement.domainType}
111
+ </DataTableCell>
112
+ <DataTableCell large>
113
+ {dataElement.valueType?.replaceAll(
114
+ '_',
115
+ ' '
116
+ )}
117
+ </DataTableCell>
118
+ <DataTableCell large>
119
+ {dataElement.createdBy.name}
120
+ </DataTableCell>
121
+ </DataTableRow>
122
+ )
123
+ }
124
+ )}
125
+ </TableBody>
126
+ </DataTable>
127
+ </div>
128
+ </div>
129
+ )
130
+ }
131
+
132
+ export default DataElementsList
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "noEmit": true,
4
+ "skipLibCheck": true,
5
+ "allowJs": true,
6
+ "jsx": "react",
7
+ "esModuleInterop": true,
8
+ "target": "ESNext",
9
+ "module": "esnext",
10
+ "moduleResolution": "node",
11
+ "baseUrl": ".",
12
+ "paths": {
13
+ "@/*": ["src/*"]
14
+ }
15
+ },
16
+ "include": ["src", "types"]
17
+ }
@@ -0,0 +1,8 @@
1
+ import 'react'
2
+
3
+ declare module 'react' {
4
+ interface StyleHTMLAttributes<T> extends React.HTMLAttributes<T> {
5
+ jsx?: boolean
6
+ global?: boolean
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ declare module '*.module.css' {
2
+ const classes: { [key: string]: string }
3
+ export default classes
4
+ }
@@ -0,0 +1,15 @@
1
+ import path from 'path'
2
+ import { defineConfig, ConfigEnv } from 'vite'
3
+
4
+ const viteConfig = defineConfig(async (configEnv: ConfigEnv) => {
5
+ const { mode } = configEnv
6
+ return {
7
+ // In dev environments, don't clear the terminal after files update
8
+ clearScreen: mode !== 'development',
9
+ // Use an import alias: import from '@/' anywhere instead of 'src/'
10
+ resolve: { alias: { '@': path.resolve(__dirname, 'src') } },
11
+ // ...other config options here
12
+ }
13
+ })
14
+
15
+ export default viteConfig
@@ -0,0 +1,10 @@
1
+ import prettierConfig from '@dhis2/config-prettier'
2
+
3
+ /**
4
+ * @type {import("prettier").Config}
5
+ */
6
+ const config = {
7
+ ...prettierConfig,
8
+ }
9
+
10
+ export default config
@@ -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,12 @@
1
+ /** @type {import('@dhis2/cli-app-scripts').D2Config} */
2
+ const config = {
3
+ type: 'app',
4
+
5
+ entryPoints: {
6
+ app: './src/AppWrapper.tsx',
7
+ },
8
+
9
+ viteConfigExtensions: './viteConfigExtensions.mts',
10
+ }
11
+
12
+ module.exports = config
@@ -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,39 @@
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:13:09.567Z\n"
9
+ "PO-Revision-Date: 2026-01-03T10:13:09.567Z\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 "Error"
21
+ msgstr "Error"
22
+
23
+ msgid "Error loading the data elements"
24
+ msgstr "Error loading the data elements"
25
+
26
+ msgid "ID"
27
+ msgstr "ID"
28
+
29
+ msgid "Name"
30
+ msgstr "Name"
31
+
32
+ msgid "Domain"
33
+ msgstr "Domain"
34
+
35
+ msgid "Value Type"
36
+ msgstr "Value Type"
37
+
38
+ msgid "Created by"
39
+ msgstr "Created by"
@@ -0,0 +1,36 @@
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
+ "react-router": "^7.11.0"
22
+ },
23
+ "devDependencies": {
24
+ "@dhis2/cli-app-scripts": "12.8.0-alpha.3",
25
+ "@dhis2/config-eslint": "^0.2.2",
26
+ "@dhis2/config-prettier": "^0.2.2",
27
+ "@eslint/compat": "^2.0.0",
28
+ "@types/jest": "^30.0.0",
29
+ "@types/react": "^19.2.7",
30
+ "@types/react-dom": "^19.2.3",
31
+ "eslint": "^9.39.2",
32
+ "prettier": "^3.7.4",
33
+ "typescript": "^5.9.3",
34
+ "vite": "^7.3.0"
35
+ }
36
+ }