@dhis2/create-app 5.3.0-alpha.4 → 5.3.0-alpha.6
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 -1
- package/src/index.js +49 -32
- package/templates/package-lock.json +46 -518
- package/templates/template-ts-dataelements-react-router/src/App.module.css +19 -10
- package/templates/template-ts-dataelements-react-router/src/AppWrapper.tsx +13 -1
- package/templates/yarn.lock +62 -183
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -42,13 +42,11 @@ const commandHandler = {
|
|
|
42
42
|
typescript: {
|
|
43
43
|
description: 'Use TypeScript or JS',
|
|
44
44
|
type: 'boolean',
|
|
45
|
-
default: true,
|
|
46
45
|
alias: ['ts', 'typeScript'],
|
|
47
46
|
},
|
|
48
47
|
template: {
|
|
49
48
|
description: 'Which template to use (Basic, With React Router)',
|
|
50
49
|
type: 'string',
|
|
51
|
-
default: 'basic',
|
|
52
50
|
},
|
|
53
51
|
packageManager: {
|
|
54
52
|
description: 'Package Manager',
|
|
@@ -58,7 +56,7 @@ const commandHandler = {
|
|
|
58
56
|
},
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
const
|
|
59
|
+
const getTemplateDirectory = (templateName) => {
|
|
62
60
|
return templateName === 'react-router'
|
|
63
61
|
? templates.templateWithReactRouter
|
|
64
62
|
: templates.templateWithList
|
|
@@ -85,37 +83,41 @@ const command = {
|
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
const selectedOptions = {
|
|
88
|
-
typeScript: argv.typescript,
|
|
86
|
+
typeScript: argv.typescript ?? true,
|
|
89
87
|
packageManager:
|
|
90
88
|
argv.packageManager ?? getPackageManager() ?? 'pnpm',
|
|
91
|
-
templateName: argv.template,
|
|
89
|
+
templateName: argv.template ?? 'basic',
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
if (!useDefauls) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
message: 'Select a template',
|
|
108
|
-
default: 'ts',
|
|
109
|
-
choices: [
|
|
110
|
-
{ name: 'Basic Template', value: 'basic' },
|
|
111
|
-
{
|
|
112
|
-
name: 'Template with React Router',
|
|
113
|
-
value: 'react-router',
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
})
|
|
93
|
+
if (argv.typeScript === undefined) {
|
|
94
|
+
const language = await select({
|
|
95
|
+
message: 'Select a language',
|
|
96
|
+
default: 'ts',
|
|
97
|
+
choices: [
|
|
98
|
+
{ name: 'JavaScript', value: 'js' },
|
|
99
|
+
{ name: 'TypeScript', value: 'ts' },
|
|
100
|
+
],
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
selectedOptions.typeScript = language === 'ts'
|
|
104
|
+
}
|
|
117
105
|
|
|
118
|
-
|
|
106
|
+
if (argv.template === undefined) {
|
|
107
|
+
const template = await select({
|
|
108
|
+
message: 'Select a template',
|
|
109
|
+
default: 'ts',
|
|
110
|
+
choices: [
|
|
111
|
+
{ name: 'Basic Template', value: 'basic' },
|
|
112
|
+
{
|
|
113
|
+
name: 'Template with React Router',
|
|
114
|
+
value: 'react-router',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
selectedOptions.templateName = template
|
|
120
|
+
}
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
reporter.info(
|
|
@@ -156,7 +158,7 @@ const command = {
|
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
reporter.info('Copying template files')
|
|
159
|
-
const templateFiles =
|
|
161
|
+
const templateFiles = getTemplateDirectory(selectedOptions.templateName)
|
|
160
162
|
fs.copySync(templateFiles, cwd)
|
|
161
163
|
|
|
162
164
|
const paths = {
|
|
@@ -166,6 +168,7 @@ const command = {
|
|
|
166
168
|
pnpmLock: path.join(cwd, 'pnpm-lock.yaml'),
|
|
167
169
|
pnpmWorkspace: path.join(cwd, 'pnpm-workspace.yaml'),
|
|
168
170
|
appRootFile: path.join(cwd, 'src/App.tsx'),
|
|
171
|
+
appRootWrapperFile: path.join(cwd, 'src/AppWrapper.tsx'),
|
|
169
172
|
initYarnLock: path.join(__dirname, '../templates/yarn.lock'),
|
|
170
173
|
initNpmLock: path.join(__dirname, '../templates/package-lock.json'),
|
|
171
174
|
}
|
|
@@ -179,6 +182,12 @@ const command = {
|
|
|
179
182
|
// Default template is with PNPM with TypeScript - some modifications here for yarn/npm/JS
|
|
180
183
|
const templateModifications = [
|
|
181
184
|
[paths.package, true, (f) => f.replace('{{template-name}}', name)],
|
|
185
|
+
[
|
|
186
|
+
paths.appRootWrapperFile,
|
|
187
|
+
true,
|
|
188
|
+
(f) => f.replace('{{template-name}}', name),
|
|
189
|
+
],
|
|
190
|
+
|
|
182
191
|
// [
|
|
183
192
|
// path.join(paths.base, '.husky/pre-commit'),
|
|
184
193
|
// !pnpm,
|
|
@@ -249,14 +258,14 @@ const command = {
|
|
|
249
258
|
// convert to JS
|
|
250
259
|
if (!typeScript) {
|
|
251
260
|
reporter.info('Preparing JavaScript template')
|
|
252
|
-
reporter.info(`
|
|
261
|
+
reporter.info(` Running '${pkgManager} install'`)
|
|
253
262
|
|
|
254
263
|
await exec({
|
|
255
264
|
cmd: pkgManager,
|
|
256
265
|
args: ['install'],
|
|
257
266
|
cwd: paths.base,
|
|
258
267
|
})
|
|
259
|
-
reporter.info('
|
|
268
|
+
reporter.info(' Converting template to JS with tsc')
|
|
260
269
|
await exec({
|
|
261
270
|
cmd: 'npx',
|
|
262
271
|
args: [
|
|
@@ -274,7 +283,7 @@ const command = {
|
|
|
274
283
|
pipe: argv.debug,
|
|
275
284
|
})
|
|
276
285
|
|
|
277
|
-
reporter.
|
|
286
|
+
reporter.debug(' Deleting TS files')
|
|
278
287
|
const filePathsToRemove = path.join(paths.base, '/src/**/*.ts[x]')
|
|
279
288
|
const filesToRemove = await fg.glob(filePathsToRemove)
|
|
280
289
|
|
|
@@ -320,6 +329,14 @@ const command = {
|
|
|
320
329
|
)} to launch your new DHIS2 application`
|
|
321
330
|
)
|
|
322
331
|
|
|
332
|
+
reporter.print(
|
|
333
|
+
`${chalk.gray(
|
|
334
|
+
`You can also run the web application with ${chalk.bold(
|
|
335
|
+
`${pkgManager} start --proxy https://YOUR_DHIS2_INSTANCE_URL`
|
|
336
|
+
)} to create a proxy on localhost to a remote DHIS2 instance. Check https://developers.dhis2.org/docs/quickstart/quickstart-web#connecting-your-web-app-to-dhis2 for more information.`
|
|
337
|
+
)}`
|
|
338
|
+
)
|
|
339
|
+
|
|
323
340
|
return
|
|
324
341
|
},
|
|
325
342
|
}
|