@dhis2/create-app 5.3.0-alpha.4 → 5.3.0-alpha.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2/create-app",
3
- "version": "5.3.0-alpha.4",
3
+ "version": "5.3.0-alpha.5",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "bin": {
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 getTemplateFile = (templateName) => {
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
- const language = await select({
96
- message: 'Select a language',
97
- default: 'ts',
98
- choices: [
99
- { name: 'JavaScript', value: 'js' },
100
- { name: 'TypeScript', value: 'ts' },
101
- ],
102
- })
103
-
104
- selectedOptions.typeScript = language === 'ts'
105
-
106
- const template = await select({
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
- selectedOptions.templateName = template
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 = getTemplateFile(selectedOptions.templateName)
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(` running '${pkgManager} install'`)
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(' convert template to JS with tsc')
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.info(' Deleting TS files')
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
 
@@ -4,7 +4,6 @@
4
4
  font-size: 14px;
5
5
  grid-template-columns: auto;
6
6
  grid-template-rows: auto 1fr auto;
7
- overflow: auto;
8
7
  }
9
8
 
10
9
  .sidebar {
@@ -20,17 +19,9 @@
20
19
  grid-area: main;
21
20
  width: 100%;
22
21
  padding-inline-start: 10px;
23
- /*height: 100%;
24
- display: flex;
25
- flex-direction: column;
26
- font-size: 1rem;
27
- max-width: 1020px;
28
- margin: 0px auto;
29
- padding-top: 8px; */
30
22
  }
31
23
 
32
24
  .noticeContainer {
33
- /* width: 768px; */
34
25
  max-width: 340px;
35
26
 
36
27
  margin: 16px 0;
@@ -45,7 +36,6 @@
45
36
  height: 100%;
46
37
  grid-template-columns: 250px 1fr;
47
38
  grid-template-rows: 1fr auto;
48
- overflow: auto;
49
39
  min-height: 1000px;
50
40
  }
51
41
 
@@ -59,3 +49,22 @@
59
49
  margin: 8px;
60
50
  margin-inline-start: 0;
61
51
  }
52
+
53
+ .footer {
54
+ display: flex;
55
+ flex-direction: column;
56
+ margin-top: 16px;
57
+ align-items: center;
58
+ gap: 6px;
59
+ background-color: rgb(44, 102, 147);
60
+ padding: 16px;
61
+ color: white;
62
+ }
63
+
64
+ .footer a,
65
+ .footer a:visited,
66
+ .footer a:active,
67
+ .footer a:link,
68
+ .footer a:focus {
69
+ color: white;
70
+ }
@@ -22,7 +22,19 @@ const AppWrapper = () => {
22
22
  <Route path="/about" element={<AboutPage />} />
23
23
  </Routes>
24
24
  </div>
25
- <div className={classes.footer}>Our App</div>
25
+ <div className={classes.footer}>
26
+ <div>{'{{template-name}}'}</div>
27
+ <div>
28
+ This web application was created using{' '}
29
+ <a
30
+ target="_blank"
31
+ rel="noreferrer"
32
+ href="https://developers.dhis2.org/docs/quickstart/quickstart-web"
33
+ >
34
+ @dhis2/create-app
35
+ </a>
36
+ </div>
37
+ </div>
26
38
  </HashRouter>
27
39
  </div>
28
40
  )