@dhis2/create-app 5.3.0-alpha.3 → 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.3",
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,48 +83,41 @@ const command = {
85
83
  }
86
84
 
87
85
  const selectedOptions = {
88
- typeScript: argv.typescript,
89
- packageManager: argv.packageManager ?? getPackageManager(),
90
- templateName: argv.template,
86
+ typeScript: argv.typescript ?? true,
87
+ packageManager:
88
+ argv.packageManager ?? getPackageManager() ?? 'pnpm',
89
+ templateName: argv.template ?? 'basic',
91
90
  }
92
91
 
93
92
  if (!useDefauls) {
94
- const packageManager = await select({
95
- message: 'Select a package manager',
96
- default: 'pnpm',
97
- choices: [
98
- { name: 'npm', value: 'npm' },
99
- { name: 'pnpm', value: 'pnpm' },
100
- { name: 'yarn 1 (legacy)', value: 'yarn' },
101
- ],
102
- })
103
-
104
- selectedOptions.packageManager = packageManager
105
-
106
- const language = await select({
107
- message: 'Select a language',
108
- default: 'ts',
109
- choices: [
110
- { name: 'JavaScript', value: 'js' },
111
- { name: 'TypeScript', value: 'ts' },
112
- ],
113
- })
114
-
115
- selectedOptions.typeScript = language === 'ts'
116
-
117
- const template = await select({
118
- message: 'Select a template',
119
- default: 'ts',
120
- choices: [
121
- { name: 'Basic Template', value: 'basic' },
122
- {
123
- name: 'Template with React Router',
124
- value: 'react-router',
125
- },
126
- ],
127
- })
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
+ }
128
105
 
129
- 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
+ }
130
121
  }
131
122
 
132
123
  reporter.info(
@@ -167,7 +158,7 @@ const command = {
167
158
  }
168
159
 
169
160
  reporter.info('Copying template files')
170
- const templateFiles = getTemplateFile(selectedOptions.templateName)
161
+ const templateFiles = getTemplateDirectory(selectedOptions.templateName)
171
162
  fs.copySync(templateFiles, cwd)
172
163
 
173
164
  const paths = {
@@ -177,6 +168,7 @@ const command = {
177
168
  pnpmLock: path.join(cwd, 'pnpm-lock.yaml'),
178
169
  pnpmWorkspace: path.join(cwd, 'pnpm-workspace.yaml'),
179
170
  appRootFile: path.join(cwd, 'src/App.tsx'),
171
+ appRootWrapperFile: path.join(cwd, 'src/AppWrapper.tsx'),
180
172
  initYarnLock: path.join(__dirname, '../templates/yarn.lock'),
181
173
  initNpmLock: path.join(__dirname, '../templates/package-lock.json'),
182
174
  }
@@ -190,6 +182,12 @@ const command = {
190
182
  // Default template is with PNPM with TypeScript - some modifications here for yarn/npm/JS
191
183
  const templateModifications = [
192
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
+
193
191
  // [
194
192
  // path.join(paths.base, '.husky/pre-commit'),
195
193
  // !pnpm,
@@ -260,14 +258,14 @@ const command = {
260
258
  // convert to JS
261
259
  if (!typeScript) {
262
260
  reporter.info('Preparing JavaScript template')
263
- reporter.info(` running '${pkgManager} install'`)
261
+ reporter.info(` Running '${pkgManager} install'`)
264
262
 
265
263
  await exec({
266
264
  cmd: pkgManager,
267
265
  args: ['install'],
268
266
  cwd: paths.base,
269
267
  })
270
- reporter.info(' convert template to JS with tsc')
268
+ reporter.info(' Converting template to JS with tsc')
271
269
  await exec({
272
270
  cmd: 'npx',
273
271
  args: [
@@ -285,7 +283,7 @@ const command = {
285
283
  pipe: argv.debug,
286
284
  })
287
285
 
288
- reporter.info(' Deleting TS files')
286
+ reporter.debug(' Deleting TS files')
289
287
  const filePathsToRemove = path.join(paths.base, '/src/**/*.ts[x]')
290
288
  const filesToRemove = await fg.glob(filePathsToRemove)
291
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
  )