@corva/create-app 0.40.0-0 → 0.41.0-1

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 (49) hide show
  1. package/README.md +19 -17
  2. package/bin/cca.js +5 -0
  3. package/bin/create-corva-app.cjs +14 -0
  4. package/lib/bump-version.option.js +17 -8
  5. package/lib/constants/cli.js +5 -11
  6. package/lib/constants/manifest.js +15 -22
  7. package/lib/constants/messages.js +4 -10
  8. package/lib/constants/package.js +6 -8
  9. package/lib/flow.js +16 -13
  10. package/lib/flows/lib/api.js +153 -84
  11. package/lib/flows/lib/create-zip-archive.js +7 -7
  12. package/lib/flows/lib/json.js +8 -8
  13. package/lib/flows/lib/manifest.js +5 -7
  14. package/lib/flows/lib/step-error.js +1 -3
  15. package/lib/flows/prepare.js +2 -4
  16. package/lib/flows/release.js +18 -10
  17. package/lib/flows/rerun.js +5 -7
  18. package/lib/flows/steps/prepare-load-app-files.js +3 -7
  19. package/lib/flows/steps/release/add-label.js +11 -0
  20. package/lib/flows/steps/release/add-notes.js +10 -0
  21. package/lib/flows/steps/release/get-config.js +37 -0
  22. package/lib/flows/steps/release/prepare-data.js +10 -0
  23. package/lib/flows/steps/release/publish.js +9 -0
  24. package/lib/flows/steps/release/remove-failed-upload.js +20 -0
  25. package/lib/flows/steps/release/upload-zip-to-corva.js +25 -0
  26. package/lib/flows/steps/release/wait-for-build.js +29 -0
  27. package/lib/flows/steps/rerun-create-task.js +22 -15
  28. package/lib/flows/steps/rerun-prepare-data.js +150 -127
  29. package/lib/flows/steps/rerun.js +3 -7
  30. package/lib/flows/steps/zip-cleanup.js +6 -6
  31. package/lib/flows/steps/zip-create-archive.js +5 -5
  32. package/lib/flows/steps/zip-file-list-resolve.js +34 -29
  33. package/lib/flows/steps/zip-prepare.js +7 -8
  34. package/lib/flows/steps/zip.js +5 -9
  35. package/lib/flows/zip-simple.js +2 -4
  36. package/lib/flows/zip.js +3 -5
  37. package/lib/helpers/logger.js +35 -0
  38. package/lib/helpers/manifest.js +6 -10
  39. package/lib/helpers/resolve-app-runtime.js +47 -45
  40. package/lib/helpers/utils.js +4 -9
  41. package/lib/helpers/versioning.js +8 -13
  42. package/lib/{index.js → main.js} +118 -116
  43. package/lib/scripts/utils/version.js +12 -13
  44. package/package.json +5 -3
  45. package/bin/create-corva-app.js +0 -5
  46. package/lib/app.js +0 -9
  47. package/lib/flows/steps/release-get-app-key.js +0 -16
  48. package/lib/flows/steps/release-get-config.js +0 -37
  49. package/lib/flows/steps/release-upload-zip-to-corva.js +0 -25
@@ -1,47 +1,57 @@
1
- #!/usr/bin/env node
2
-
3
- 'use strict';
4
-
5
- const chalk = require('chalk');
6
- const figlet = require('figlet');
7
- const { Command, CommanderError, Option } = require('commander');
8
- const fs = require('fs-extra');
9
- const inquirer = require('inquirer');
10
- const os = require('os');
11
- const path = require('path');
12
- const semver = require('semver');
13
-
14
- const {
1
+ import chalk from 'chalk';
2
+ import figlet from 'figlet';
3
+ import { Command, CommanderError, Option } from 'commander';
4
+ import fs from 'fs-extra';
5
+ import inquirer from 'inquirer';
6
+ import os from 'node:os';
7
+ import path from 'node:path';
8
+ import semver from 'semver';
9
+
10
+ import {
15
11
  ensureLatestVersion,
16
12
  warnIfOutdated,
17
13
  ensureBumpVersion,
18
- } = require('./scripts/utils/version');
19
- const utils = require('./helpers/utils.js');
20
- const manifestHelpers = require('./helpers/manifest.js');
21
- const versioning = require('./helpers/versioning.js');
22
-
23
- const { getDefaultsForPackageJson } = require('./constants/package.js');
24
- const manifestConstants = require('./constants/manifest.js');
25
-
26
- const packageJson = require('../package.json');
27
- const { clear } = require('console');
28
- const spawn = require('cross-spawn');
29
- const { runFlow } = require('./flow');
30
- const { ERROR_ICON } = require('./constants/messages');
31
- const { StepError } = require('./flows/lib/step-error');
32
- const { RELEASE_FLOW } = require('./flows/release');
33
- const { RERUN_FLOW } = require('./flows/rerun');
34
- const { ZIP_FLOW } = require('./flows/zip');
35
- const { bumpVersionOptionDeprecated, bumpVersionOption } = require('./bump-version.option');
36
- const { Manifest } = require('./flows/lib/manifest');
37
- const { resolveAppRuntime } = require('./helpers/resolve-app-runtime');
38
- const { existsSync } = require('fs');
14
+ } from './scripts/utils/version.js';
15
+ import * as utils from './helpers/utils.js';
16
+ import * as manifestHelpers from './helpers/manifest.js';
17
+ import * as versioning from './helpers/versioning.js';
18
+
19
+ import { getDefaultsForPackageJson } from './constants/package.js';
20
+ import * as manifestConstants from './constants/manifest.js';
21
+
22
+ import packageJson from '../package.json' assert { type: 'json' };
23
+ import { clear } from 'node:console';
24
+ import spawn from 'cross-spawn';
25
+ import { runFlow } from './flow.js';
26
+ import { ERROR_ICON } from './constants/messages.js';
27
+ import { StepError } from './flows/lib/step-error.js';
28
+ import { RELEASE_FLOW } from './flows/release.js';
29
+ import { RERUN_FLOW } from './flows/rerun.js';
30
+ import { ZIP_FLOW } from './flows/zip.js';
31
+ import { bumpVersionOptionDeprecated, bumpVersionOption, apiKeyOption, envOption, silentOption } from './bump-version.option.js';
32
+ import { Manifest } from './flows/lib/manifest.js';
33
+ import { resolveAppRuntime } from './helpers/resolve-app-runtime.js';
34
+ import { existsSync } from 'node:fs';
35
+ import { fileURLToPath } from 'node:url';
36
+ import { logger } from './helpers/logger.js';
37
+ import _ from 'lodash/fp.js';
38
+
39
+ const __filename = fileURLToPath(import.meta.url);
40
+ const __dirname = path.dirname(__filename);
39
41
 
40
42
  const writejsonOptions = {
41
43
  spaces: 2,
42
44
  EOL: os.EOL,
43
45
  };
44
46
 
47
+ const silencer = handler => async (...args) => {
48
+ const result = await handler(...args);
49
+
50
+ if (args[args.length - 2].silent && result) {
51
+ console.log(result);
52
+ }
53
+ }
54
+
45
55
  function startingMessage() {
46
56
  clear();
47
57
  console.log(chalk.green(' Welcome to apps generator for:'));
@@ -49,11 +59,11 @@ function startingMessage() {
49
59
  }
50
60
 
51
61
  function checkNodeVersion() {
52
- process.stdout.write('Checking node version...');
62
+ logger.write('Checking node version...');
53
63
 
54
64
  const unsupportedNodeVersion = !semver.satisfies(process.version, '>=16');
55
65
  if (unsupportedNodeVersion) {
56
- console.log(
66
+ logger.log(
57
67
  chalk.red(
58
68
  `\nYou are using Node ${process.version}.\n\n` +
59
69
  `Please update to Node 16 or higher for a better, fully supported experience.\n`
@@ -62,7 +72,7 @@ function checkNodeVersion() {
62
72
  // Fall back to latest supported react-scripts on Node 4
63
73
  return process.exit(1);
64
74
  }
65
- process.stdout.write(' ✅ \n');
75
+ logger.write(' ✅ \n');
66
76
  }
67
77
 
68
78
  function checkOptions(opts) {
@@ -89,7 +99,7 @@ const printDeprecationNotice = (param) =>
89
99
  ` Use ${chalk.cyan(`create-corva-app ${param} .`)} instead`
90
100
  );
91
101
 
92
- async function initialChecks() {
102
+ export async function run() {
93
103
  const program = new Command()
94
104
  .hook('preAction', async () => {
95
105
  checkNodeVersion();
@@ -110,7 +120,7 @@ async function initialChecks() {
110
120
  const option = new Option(
111
121
  `${value.alias ? `-${value.alias}, ` : ''}--${value.name} [${(type !== 'undefined' && type) || 'string'
112
122
  }]`,
113
- value.message
123
+ value.message,
114
124
  );
115
125
 
116
126
  if (value.choices) {
@@ -136,37 +146,12 @@ async function initialChecks() {
136
146
 
137
147
  createCommand
138
148
  .version(packageJson.version)
139
- .addOption(
140
- new Option(
141
- '-z, --zip [string]',
142
- chalk.bgYellow`DEPRECATED` + ` Use ${chalk.cyan`zip`} command instead`
143
- )
144
- )
145
- .addOption(
146
- new Option(
147
- '--release',
148
- chalk.bgYellow`DEPRECATED` + ` Use ${chalk.cyan`release`} command instead`
149
- )
150
- )
151
- .addOption(bumpVersionOptionDeprecated);
152
149
 
153
150
  createCommand.action(async (dirName, options) => {
154
151
  if (options.zip || options.release) {
155
152
  options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
156
153
  }
157
154
 
158
- if (options.zip) {
159
- printDeprecationNotice('zip');
160
-
161
- return runFlow(ZIP_FLOW, { dirName, patterns: [], options });
162
- }
163
-
164
- if (options.release) {
165
- printDeprecationNotice('release');
166
-
167
- return runFlow(RELEASE_FLOW, { dirName, patterns: [], options });
168
- }
169
-
170
155
  startingMessage();
171
156
 
172
157
  // NOTE: Default action
@@ -180,11 +165,12 @@ async function initialChecks() {
180
165
  .argument('[patterns...]', 'Additional patterns to zip', [])
181
166
  .addOption(bumpVersionOption)
182
167
  .addOption(new Option('--ignored-files [ignoredFiles...]', 'Patterns to skip zip', []))
183
- .action(async (dirName, patterns, options) => {
168
+ .addOption(silentOption)
169
+ .action(silencer(async (dirName, patterns, options) => {
184
170
  options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
185
171
 
186
- return runFlow(ZIP_FLOW, { dirName, patterns, options });
187
- });
172
+ return runFlow(ZIP_FLOW, { dirName, patterns, options }).then(_.get('zipFileName'))
173
+ }));
188
174
 
189
175
  program
190
176
  .command('release')
@@ -192,20 +178,30 @@ async function initialChecks() {
192
178
  .argument('<project-directory>', 'Project directory to work with')
193
179
  .argument('[patterns...]', 'Additional patterns to zip', [])
194
180
  .addOption(bumpVersionOption)
195
- .addOption(new Option('--ignored-files [ignoredFiles...]', 'Patterns to skip zip', []))
181
+ .addOption(new Option('--ignored-files [string...]', 'Patterns to skip zip').default([]))
182
+ .addOption(silentOption)
183
+ .addOption(envOption)
184
+ .addOption(apiKeyOption)
185
+ .addOption(new Option('--notes [string]', 'Add custom notes to published app'))
186
+ .addOption(new Option('--label [string]', 'Put a label on the release').choices(['BETA', 'PROD']))
187
+ .addOption(new Option('--remove-on-fail [boolean]', 'Remove release if it fails during deployment').default(false))
188
+ // .addOption(new Option('--zip-file-name [string]', 'Prebuilt zip file name in dir'))
196
189
  .action(async (dirName, patterns, options) => {
197
190
  options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
198
191
 
199
- return runFlow(RELEASE_FLOW, { dirName, patterns, options });
192
+ await runFlow(RELEASE_FLOW, { dirName, patterns, options });
200
193
  });
201
194
 
202
195
  program
203
196
  .command('rerun')
204
197
  .description('Rerun app')
205
198
  .argument('<project-directory>', 'Project directory to work with')
199
+ .addOption(apiKeyOption)
200
+ .addOption(envOption)
201
+ .addOption(silentOption)
206
202
  .addOption(new Option('--assets [assets...]', 'Assets ids list', []))
207
- .action(async (dirName, patterns, options) => {
208
- return runFlow(RERUN_FLOW, { dirName, patterns, options });
203
+ .action(async (dirName, options) => {
204
+ await runFlow(RERUN_FLOW, { dirName, options });
209
205
  });
210
206
 
211
207
  try {
@@ -224,7 +220,7 @@ const handleError = (e) => {
224
220
  return;
225
221
  }
226
222
 
227
- process.stdout.write(ERROR_ICON);
223
+ logger.write(ERROR_ICON);
228
224
 
229
225
  if (!(e instanceof StepError)) {
230
226
  console.error(chalk.red(e));
@@ -245,16 +241,16 @@ const handleCommanderError = (e) => {
245
241
  const commandName = program.args[0] || program._defaultCommandName;
246
242
 
247
243
  console.error('Please specify the project directory:');
248
- console.log(
244
+ logger.log(
249
245
  ` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('<project-directory>')}`
250
246
  );
251
- console.log();
252
- console.log('For example:');
253
- console.log(
247
+ logger.log();
248
+ logger.log('For example:');
249
+ logger.log(
254
250
  ` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('my-react-app')}`
255
251
  );
256
- console.log();
257
- console.log(
252
+ logger.log();
253
+ logger.log(
258
254
  `Run ${chalk.cyan(`${program.name()} help ${commandName}`)} to see all options.`
259
255
  );
260
256
  } else {
@@ -278,7 +274,7 @@ async function initPackage(projectName, opts) {
278
274
  const manifest = new Manifest(manifestHelpers.fillManifest(opts));
279
275
  const runtime = resolveAppRuntime(opts);
280
276
 
281
- if (!await runtime.isRuntimeAvailable()) {
277
+ if (!(await runtime.isRuntimeAvailable())) {
282
278
  throw new Error(`Runtime "${opts.runtime}" is not available locally`);
283
279
  }
284
280
 
@@ -288,7 +284,7 @@ async function initPackage(projectName, opts) {
288
284
 
289
285
  const root = path.resolve(projectName);
290
286
 
291
- console.log(`Creating a new Corva app in ${chalk.green(root)}.`);
287
+ logger.log(`Creating a new Corva app in ${chalk.green(root)}.`);
292
288
 
293
289
  if (fs.existsSync(root)) {
294
290
  throw new Error(`Directory already exists: ${root}`);
@@ -300,7 +296,7 @@ async function initPackage(projectName, opts) {
300
296
  await configureApp(root, manifest, runtime);
301
297
  await installApp(root, manifest, runtime);
302
298
 
303
- console.log();
299
+ logger.log();
304
300
  }
305
301
 
306
302
  async function createApp(dirName, opts) {
@@ -308,7 +304,7 @@ async function createApp(dirName, opts) {
308
304
 
309
305
  if (isValid) {
310
306
  Object.keys(values).forEach((key) => {
311
- console.log(`${key} : ${values[key]}`);
307
+ logger.log(`${key} : ${values[key]}`);
312
308
  });
313
309
 
314
310
  return initPackage(dirName, opts);
@@ -328,8 +324,8 @@ async function createApp(dirName, opts) {
328
324
  * @param {*} runtime
329
325
  */
330
326
  async function addTemplate(root, manifest, runtime) {
331
- console.log(chalk.green('Copying app template...'));
332
- console.log();
327
+ logger.log(chalk.green('Copying app template...'));
328
+ logger.log();
333
329
 
334
330
  const templateFolder = path.resolve(
335
331
  __dirname,
@@ -354,7 +350,7 @@ async function addTemplate(root, manifest, runtime) {
354
350
  // That's why we manually rename gitignore to .gitignore after copying template
355
351
  fs.renameSync(path.join(root, 'gitignore'), path.join(root, '.gitignore'));
356
352
 
357
- console.log(chalk.green('Done: copying app template!'));
353
+ logger.log(chalk.green('Done: copying app template!'));
358
354
  }
359
355
 
360
356
  /**
@@ -380,7 +376,7 @@ async function configureApp(root, manifest, runtime) {
380
376
 
381
377
  const addNvmRc = async (root, manifest, runtime) => {
382
378
  await fs.outputFile(path.join(root, '.nvmrc'), `${runtime.version}\n`);
383
- }
379
+ };
384
380
 
385
381
  const addTsConfigs = (root, manifest, runtime) => {
386
382
  if (runtime.language !== 'typescript') {
@@ -455,7 +451,7 @@ function addPackageJSON(root, manifest, runtime) {
455
451
  scripts: defaults.scripts,
456
452
  dependencies: defaults.dependencies,
457
453
  devDependencies: defaults.devDependencies,
458
- ...(defaults.jest && { jest: defaults.jest })
454
+ ...(defaults.jest && { jest: defaults.jest }),
459
455
  };
460
456
 
461
457
  return fs.writeJSON(path.join(root, 'package.json'), packageJson, writejsonOptions);
@@ -469,12 +465,20 @@ function addPackageJSON(root, manifest, runtime) {
469
465
  async function installApp(root, manifest, runtime) {
470
466
  const command = manifest.isJs() ? runtime.packageManager : 'make';
471
467
  const args = ['install'];
472
- const opts = { stdio: ['inherit', 'inherit', 'pipe'], cwd: root }
468
+ const opts = { stdio: ['inherit', 'inherit', 'pipe'], cwd: root };
473
469
 
474
- console.log(chalk.yellow(`Installing template dependencies using ${runtime.packageManager}...`));
475
- const proc = manifest.isJs() && existsSync(`${os.homedir()}/.nvm/nvm.sh`) ?
476
- spawn.sync(`\\. ${os.homedir()}/.nvm/nvm.sh && nvm i && ${command} ${args.join(' ')}`, { shell: true, ...opts }) :
477
- spawn.sync(command, args, opts);
470
+ if (process.env.CI && command === 'yarn') {
471
+ args.push('--cache-folder=".yarn-cache"');
472
+ }
473
+
474
+ logger.log(chalk.yellow(`Installing template dependencies using ${runtime.packageManager}...`));
475
+ const proc =
476
+ manifest.isJs() && existsSync(`${os.homedir()}/.nvm/nvm.sh`)
477
+ ? spawn.sync(`\\. ${os.homedir()}/.nvm/nvm.sh && nvm i && ${command} ${args.join(' ')}`, {
478
+ shell: true,
479
+ ...opts,
480
+ })
481
+ : spawn.sync(command, args, opts);
478
482
 
479
483
  if (proc.stderr) {
480
484
  const error = proc.stderr
@@ -491,20 +495,20 @@ async function installApp(root, manifest, runtime) {
491
495
  return;
492
496
  }
493
497
 
494
- console.log(chalk.green('Successfull project install'));
498
+ logger.log(chalk.green('Successfull project install'));
495
499
 
496
500
  if (versioning.tryGitInit(root)) {
497
- console.log();
498
- console.log('Initialized a git repository.');
501
+ logger.log();
502
+ logger.log('Initialized a git repository.');
499
503
 
500
504
  if (versioning.tryGitCommit(root)) {
501
- console.log();
502
- console.log('Created git commit.');
505
+ logger.log();
506
+ logger.log('Created git commit.');
503
507
  }
504
508
  }
505
509
 
506
- console.log();
507
- console.log(`Success! Created ${manifest.name} at ${root}`);
510
+ logger.log();
511
+ logger.log(`Success! Created ${manifest.name} at ${root}`);
508
512
 
509
513
  helpCommands(manifest, runtime);
510
514
  }
@@ -516,20 +520,18 @@ async function helpCommands(manifest, { packageManager: displayedCommand }) {
516
520
 
517
521
  const useYarn = displayedCommand === 'yarn';
518
522
 
519
- console.log('Inside that directory, you can run several commands:');
520
- console.log();
521
- console.log(chalk.cyan(` ${displayedCommand} start`));
522
- console.log(' Starts the development server.');
523
- console.log();
524
- console.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}build`));
525
- console.log(' Bundles the app into static files for production.');
526
- console.log();
527
- console.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}zip`));
528
- console.log(' Bundles the app into ZIP file in app root directory');
529
- console.log();
530
- console.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}release`));
531
- console.log(' Uploads the app ZIP to Corva');
532
- console.log();
523
+ logger.log('Inside that directory, you can run several commands:');
524
+ logger.log();
525
+ logger.log(chalk.cyan(` ${displayedCommand} start`));
526
+ logger.log(' Starts the development server.');
527
+ logger.log();
528
+ logger.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}build`));
529
+ logger.log(' Bundles the app into static files for production.');
530
+ logger.log();
531
+ logger.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}zip`));
532
+ logger.log(' Bundles the app into ZIP file in app root directory');
533
+ logger.log();
534
+ logger.log(chalk.cyan(` ${displayedCommand} ${useYarn ? '' : 'run '}release`));
535
+ logger.log(' Uploads the app ZIP to Corva');
536
+ logger.log();
533
537
  }
534
-
535
- initialChecks();
@@ -1,9 +1,10 @@
1
- const NpmApi = require('npm-api');
2
- const chalk = require('chalk');
3
- const semver = require('semver');
4
- const inquirer = require('inquirer');
1
+ import NpmApi from 'npm-api';
2
+ import chalk from 'chalk';
3
+ import semver from 'semver';
4
+ import inquirer from 'inquirer';
5
5
 
6
- const packageJson = require('../../../package.json');
6
+ import packageJson from '../../../package.json' assert { type: 'json' };
7
+ import { logger } from '../../helpers/logger.js';
7
8
  const npm = new NpmApi();
8
9
 
9
10
  const error = chalk.bold.red;
@@ -15,7 +16,7 @@ const getCurrentVersion = () => packageJson.version;
15
16
  const getLatestVersion = async () => npm.repo('@corva/create-app').prop('version');
16
17
 
17
18
  // NOTE: Stop process and show error if version is outdated
18
- async function ensureLatestVersion() {
19
+ export async function ensureLatestVersion() {
19
20
  const currentVersion = getCurrentVersion();
20
21
  const latestVersion = await getLatestVersion();
21
22
 
@@ -36,8 +37,8 @@ async function ensureLatestVersion() {
36
37
  }
37
38
 
38
39
  // NOTE: Show user-friendly warning if version is outdated
39
- async function warnIfOutdated() {
40
- process.stdout.write('Checking for updates...\n');
40
+ export async function warnIfOutdated() {
41
+ logger.write('Checking for updates...\n');
41
42
 
42
43
  const currentVersion = getCurrentVersion();
43
44
  const latestVersion = await getLatestVersion();
@@ -55,7 +56,7 @@ async function warnIfOutdated() {
55
56
  `);
56
57
  console.log(warning(asterisks));
57
58
  } else {
58
- process.stdout.write(' ✅ \n');
59
+ logger.write(' ✅ \n');
59
60
  }
60
61
  }
61
62
 
@@ -63,7 +64,7 @@ const PROMPT_MESSAGE = `Bumping package version:
63
64
  ${chalk.bold` Please select one of the options below:`}
64
65
  `;
65
66
 
66
- const ensureBumpVersion = async (bumpVersion) => {
67
+ export const ensureBumpVersion = async (bumpVersion) => {
67
68
  if (bumpVersion) {
68
69
  return bumpVersion;
69
70
  }
@@ -95,7 +96,7 @@ const ensureBumpVersion = async (bumpVersion) => {
95
96
  return option === 'custom' ? custom : option;
96
97
  };
97
98
 
98
- async function getIncreasedVersion(version, { bumpVersion: releaseTypeOrNewVersion }) {
99
+ export async function getIncreasedVersion(version, { bumpVersion: releaseTypeOrNewVersion }) {
99
100
  if (releaseTypeOrNewVersion === 'skip') {
100
101
  return version;
101
102
  }
@@ -106,5 +107,3 @@ async function getIncreasedVersion(version, { bumpVersion: releaseTypeOrNewVersi
106
107
 
107
108
  return semver.inc(version, releaseTypeOrNewVersion);
108
109
  }
109
-
110
- module.exports = { ensureLatestVersion, warnIfOutdated, getIncreasedVersion, ensureBumpVersion };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.40.0-0",
3
+ "version": "0.41.0-1",
4
4
  "private": false,
5
5
  "description": "Create app to use it in CORVA.AI",
6
6
  "keywords": [
@@ -15,10 +15,12 @@
15
15
  "directory": "@corva/create-app"
16
16
  },
17
17
  "license": "MIT",
18
+ "type": "module",
18
19
  "bin": {
19
- "create-corva-app": "./bin/create-corva-app.js"
20
+ "create-corva-app": "./bin/create-corva-app.cjs"
20
21
  },
21
22
  "files": [
23
+ "bin/**/*.cjs",
22
24
  "bin/**/*.js",
23
25
  "lib/**/*.js",
24
26
  "templates",
@@ -33,7 +35,6 @@
33
35
  },
34
36
  "dependencies": {
35
37
  "archiver": "^5.3.0",
36
- "axios": "^0.25.0",
37
38
  "chalk": "4.1.0",
38
39
  "commander": "^9.1.0",
39
40
  "cross-spawn": "7.0.3",
@@ -43,6 +44,7 @@
43
44
  "form-data": "^4.0.0",
44
45
  "fs-extra": "9.0.1",
45
46
  "glob": "^8.0.1",
47
+ "got": "^12.5.1",
46
48
  "inquirer": "^8.2.3",
47
49
  "is-glob": "^4.0.3",
48
50
  "lodash": "^4.17.21",
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { run } = require('../lib/app');
4
-
5
- run();
package/lib/app.js DELETED
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- const run = () => {
4
- require('./');
5
- };
6
-
7
- module.exports = {
8
- run,
9
- };
@@ -1,16 +0,0 @@
1
- const { RELEASE } = require('../../constants/messages');
2
-
3
- const GET_APP_KEY_STEP = {
4
- message: RELEASE.getAppKey,
5
- fn: ({ manifest }) => {
6
- const appKey = manifest.manifest.application.key;
7
-
8
- if (!appKey) {
9
- throw new Error(RELEASE.getAppKeyError);
10
- }
11
-
12
- return { appKey };
13
- },
14
- };
15
-
16
- module.exports = { GET_APP_KEY_STEP };
@@ -1,37 +0,0 @@
1
- const { RELEASE } = require('../../constants/messages');
2
- const { promises: fs } = require('fs');
3
- const dotenv = require('dotenv');
4
- const { resolve } = require('path');
5
- const { StepError } = require('../lib/step-error');
6
-
7
- async function getVarsFromDotEnv({ dirName }) {
8
- try {
9
- const envFile = await fs.readFile(resolve(dirName, '.env'));
10
- return dotenv.parse(envFile);
11
- } catch (error) {
12
- return {};
13
- }
14
- }
15
-
16
- const GET_RELEASE_CONFIG_STEP = {
17
- message: RELEASE.getAuthToken,
18
- fn: async ({ dirName }) => {
19
- const parsedEnv = await getVarsFromDotEnv({ dirName });
20
-
21
- const CORVA_API_ENV = process.env.CORVA_API_ENV || parsedEnv.CORVA_API_ENV;
22
- const AUTH_TOKEN = process.env.AUTH_TOKEN || parsedEnv.AUTH_TOKEN;
23
- const API_KEY = process.env.API_KEY || parsedEnv.API_KEY;
24
-
25
- if (!AUTH_TOKEN && !API_KEY) {
26
- throw new StepError(RELEASE.getAuthTokenError);
27
- }
28
-
29
- return {
30
- CORVA_API_ENV: CORVA_API_ENV || 'production',
31
- AUTH_TOKEN,
32
- API_KEY,
33
- };
34
- },
35
- };
36
-
37
- module.exports = { GET_RELEASE_CONFIG_STEP };
@@ -1,25 +0,0 @@
1
- const { RELEASE } = require('../../constants/messages');
2
- const FormData = require('form-data');
3
- const { resolve } = require('path');
4
- const { createReadStream } = require('fs');
5
- const { StepError } = require('../lib/step-error');
6
- const { Api } = require('../lib/api');
7
- const { get } = require('lodash/fp');
8
-
9
- const UPLOAD_ZIP_TO_CORVA_STEP = {
10
- message: RELEASE.uploadApp,
11
- fn: async ({ zipFileName, appKey, CORVA_API_ENV, AUTH_TOKEN, API_KEY, dirName }) => {
12
- const form = new FormData();
13
- form.append('package', createReadStream(resolve(dirName, zipFileName)), 'archive.zip');
14
-
15
- const api = new Api(CORVA_API_ENV, API_KEY, AUTH_TOKEN);
16
- api.uploadPackages(appKey, form).catch((e) => {
17
- throw new StepError(
18
- `${get('response.data.message', e) || ''} \nPOST: ${uploadURL} failed.`,
19
- { cause: e }
20
- );
21
- });
22
- },
23
- };
24
-
25
- module.exports = { UPLOAD_ZIP_TO_CORVA_STEP };