@corva/create-app 0.44.0-2 → 0.44.0

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.
@@ -228,4 +228,9 @@ export const manifestOptions = (projectName = 'Corva Dev Center App') => [
228
228
  message: 'Only log result of the operation',
229
229
  default: false,
230
230
  },
231
+ {
232
+ name: 'silent',
233
+ message: 'Only log result of the operation',
234
+ default: false,
235
+ },
231
236
  ];
@@ -48,7 +48,6 @@ export class Api {
48
48
  .json();
49
49
 
50
50
  const app = data.find((app) => app.attributes.app_key === appKey);
51
-
52
51
  if (!app) {
53
52
  throw new Error(`App with key - ${appKey}, not exist`);
54
53
  }
@@ -125,7 +124,6 @@ export class Api {
125
124
  searchParams: { status, per_page: perPage },
126
125
  })
127
126
  .json();
128
-
129
127
  return data;
130
128
  }
131
129
 
@@ -293,7 +291,6 @@ export class Api {
293
291
  console.log(`v2/apps/${appId}/packages/${id}`, {
294
292
  json: { package: { status: 'published' } },
295
293
  });
296
-
297
294
  const { data } = await this.#api
298
295
  .patch(`v2/apps/${appId}/packages/${id}`, {
299
296
  json: { package: { status: 'published' } },
@@ -317,7 +314,6 @@ export class Api {
317
314
  */
318
315
  async getAppPackages(appId) {
319
316
  const { data } = await this.#api.get(`v2/apps/${appId}/packages`).json();
320
-
321
317
  return data;
322
318
  }
323
319
 
@@ -91,7 +91,6 @@ export class Notification {
91
91
  */
92
92
  getStreamLink(title, streamId) {
93
93
  const streamUrl = `${this.#prefixUrl}/config/streams/${streamId}`;
94
-
95
94
  return this._createLink(title, streamUrl);
96
95
  }
97
96
 
@@ -107,7 +106,6 @@ export class Notification {
107
106
  */
108
107
  printStreamLink(title, streamId) {
109
108
  const link = this.getStreamLink(title, streamId);
110
-
111
109
  this.print(link);
112
110
  }
113
111
 
@@ -123,7 +121,6 @@ export class Notification {
123
121
  */
124
122
  getAssetLink(title, assetId) {
125
123
  const assetUrl = `${this.#prefixUrl}/assets/${assetId}`;
126
-
127
124
  return this._createLink(title, assetUrl);
128
125
  }
129
126
 
@@ -65,7 +65,6 @@ const getAssetsListWithPrompt = (assets, notification) => {
65
65
  const mapAssetsStreamsData = (assets, streamsData) => {
66
66
  return assets.map((asset) => {
67
67
  const currentStreams = streamsData.filter((stream) => stream.asset_id === parseInt(asset.id));
68
-
69
68
  return {
70
69
  assetId: asset.id,
71
70
  assetName: asset.attributes.name,
@@ -104,7 +103,6 @@ const getAssetsStreamsWithPrompt = async (mappedAssetsStreamsData, appId, notifi
104
103
 
105
104
  if (streamsWithoutCurrentApp.length === 1) {
106
105
  mappedData.selectedStreams = streamsWithoutCurrentApp;
107
-
108
106
  continue;
109
107
  }
110
108
 
@@ -9,7 +9,6 @@ import { Notification } from '../../lib/notification.js';
9
9
  async function getVarsFromDotEnv({ dirName }) {
10
10
  try {
11
11
  const envFile = await fs.readFile(resolve(dirName, '.env'));
12
-
13
12
  return dotenv.parse(envFile);
14
13
  } catch (error) {
15
14
  return {};
@@ -43,7 +43,6 @@ export const CREATE_TASK_STEP = {
43
43
  .queueAppRun(app.id, version, interval, wellId, appDatasetsNames, streamId)
44
44
  .catch((e) => {
45
45
  console.log(e.response.body);
46
-
47
46
  throw e;
48
47
  });
49
48
 
@@ -33,7 +33,6 @@ export const GET_APP_VERSION_TASK_STEP = {
33
33
  */
34
34
  const getAppVersion = async (appId, optionAppVersion, api) => {
35
35
  logger.write('\n Checking app versions...');
36
-
37
36
  const appPackages = await api.getAppPackages(appId);
38
37
 
39
38
  if (!appPackages.length) {
@@ -65,7 +65,6 @@ export const PREPARE_DATA_TASK_STEP = {
65
65
  */
66
66
  const promptAreYouSure = async () => {
67
67
  logger.log('\n');
68
-
69
68
  const answers = await inquirer.prompt([
70
69
  {
71
70
  message:
@@ -79,7 +78,6 @@ const promptAreYouSure = async () => {
79
78
  default: false,
80
79
  },
81
80
  ]);
82
-
83
81
  return answers.option;
84
82
  };
85
83
 
@@ -104,7 +104,6 @@ const getWellWithPrompt = async (wells, api) => {
104
104
  const [well] = choices;
105
105
 
106
106
  logger.write(`\n\n${chalk.black.underline.bold(`Process well - ${chalk.green(well.name)}`)}`);
107
-
108
107
  return well.value;
109
108
  }
110
109
 
@@ -144,7 +143,6 @@ const prepareWellAndStreamData = async (assets, api, manifest) => {
144
143
 
145
144
  const wells = await api.getWellByAssetId(assetId);
146
145
  const well = await getWellWithPrompt(wells, api);
147
-
148
146
  mappedAssetsToWells.set(well.attributes.asset_id, well);
149
147
 
150
148
  logger.write('\n Loading streams...');
@@ -166,7 +164,6 @@ const prepareWellAndStreamData = async (assets, api, manifest) => {
166
164
  assetsToDelete.push(assetId);
167
165
 
168
166
  if (mappedAssetsToWells.has(assetId)) mappedAssetsToWells.delete(assetId);
169
-
170
167
  if (mappedAssetsToStreams.has(assetId)) mappedAssetsToStreams.delete(assetId);
171
168
  }
172
169
  }
@@ -16,7 +16,6 @@ export function isInGitRepository(appPath) {
16
16
  return true;
17
17
  } catch (e) {
18
18
  debug(e);
19
-
20
19
  return false;
21
20
  }
22
21
  }
@@ -33,12 +32,10 @@ export function tryGitInit(appPath) {
33
32
 
34
33
  execSync('git init', { stdio: 'ignore', cwd: appPath });
35
34
  logger.log('Initialized git repo in app');
36
-
37
35
  return true;
38
36
  } catch (e) {
39
37
  debug(e);
40
38
  console.warn('Git repo not initialized');
41
-
42
39
  return false;
43
40
  }
44
41
  }
@@ -51,7 +48,6 @@ export function tryGitCommit(appPath) {
51
48
  cwd: appPath,
52
49
  });
53
50
  logger.log('Added first git commit');
54
-
55
51
  return true;
56
52
  } catch (e) {
57
53
  // We couldn't commit in already initialized git repo,
@@ -82,7 +78,6 @@ export function shouldUseYarn(appPath) {
82
78
  return true;
83
79
  } catch (e) {
84
80
  debug(e);
85
-
86
81
  return false;
87
82
  }
88
83
  }
package/lib/main.js CHANGED
@@ -1,45 +1,44 @@
1
- /* eslint-disable no-undef */
2
1
  import chalk from 'chalk';
3
- import { Command, CommanderError, Option } from 'commander';
4
2
  import figlet from 'figlet';
3
+ import { Command, CommanderError, Option } from 'commander';
5
4
  import fs from 'fs-extra';
6
5
  import inquirer from 'inquirer';
7
6
  import os from 'node:os';
8
7
  import path, { resolve } from 'node:path';
9
8
  import semver from 'semver';
10
9
 
11
- import * as manifestHelpers from './helpers/manifest.js';
10
+ import { ensureLatestVersion, warnIfOutdated, ensureBumpVersion } from './scripts/utils/version.js';
12
11
  import * as utils from './helpers/utils.js';
12
+ import * as manifestHelpers from './helpers/manifest.js';
13
13
  import * as versioning from './helpers/versioning.js';
14
- import { ensureBumpVersion, ensureLatestVersion, warnIfOutdated } from './scripts/utils/version.js';
15
14
 
16
- import * as manifestConstants from './constants/manifest.js';
17
15
  import { getDefaultsForPackageJson } from './constants/package.js';
16
+ import * as manifestConstants from './constants/manifest.js';
18
17
 
19
- import spawn from 'cross-spawn';
20
- import _ from 'lodash/fp.js';
21
- import { clear } from 'node:console';
22
- import { existsSync } from 'node:fs';
23
- import { fileURLToPath } from 'node:url';
24
18
  import packageJson from '../package.json' assert { type: 'json' };
19
+ import { clear } from 'node:console';
20
+ import spawn from 'cross-spawn';
21
+ import { runFlow } from './flow.js';
22
+ import { ERROR_ICON } from './constants/messages.js';
23
+ import { StepError } from './flows/lib/step-error.js';
24
+ import { RELEASE_FLOW } from './flows/release.js';
25
+ import { RERUN_FLOW } from './flows/rerun.js';
26
+ import { ATTACH_FLOW } from './flows/attach.js';
27
+ import { ZIP_FLOW } from './flows/zip.js';
25
28
  import {
26
- apiKeyOption,
27
- appVersion,
28
29
  bumpVersionOption,
30
+ apiKeyOption,
29
31
  envOption,
30
- originalCwdOption,
31
32
  silentOption,
33
+ appVersion,
34
+ originalCwdOption,
32
35
  } from './bump-version.option.js';
33
- import { ERROR_ICON } from './constants/messages.js';
34
- import { runFlow } from './flow.js';
35
- import { ATTACH_FLOW } from './flows/attach.js';
36
36
  import { Manifest } from './flows/lib/manifest.js';
37
- import { StepError } from './flows/lib/step-error.js';
38
- import { RELEASE_FLOW } from './flows/release.js';
39
- import { RERUN_FLOW } from './flows/rerun.js';
40
- import { ZIP_FLOW } from './flows/zip.js';
41
- import { logger } from './helpers/logger.js';
42
37
  import { IS_WINDOWS, resolveAppRuntime } from './helpers/resolve-app-runtime.js';
38
+ import { existsSync } from 'node:fs';
39
+ import { fileURLToPath } from 'node:url';
40
+ import { logger } from './helpers/logger.js';
41
+ import _ from 'lodash/fp.js';
43
42
 
44
43
  const __filename = fileURLToPath(import.meta.url);
45
44
  const __dirname = path.dirname(__filename);
@@ -59,7 +58,7 @@ const silencer =
59
58
  }
60
59
  };
61
60
 
62
- const getRealWorkingDir = (relativePath, options) => resolve(options.originalCwd, relativePath);
61
+ const getRealWorkingDir = (relativePath, options) => resolve(options.originalCwd, relativePath)
63
62
 
64
63
  function startingMessage() {
65
64
  clear();
@@ -71,19 +70,16 @@ function checkNodeVersion() {
71
70
  logger.write('Checking node version...');
72
71
 
73
72
  const unsupportedNodeVersion = !semver.satisfies(process.version, '>=16');
74
-
75
73
  if (unsupportedNodeVersion) {
76
74
  logger.log(
77
75
  chalk.red(
78
76
  `\nYou are using Node ${process.version}.\n\n` +
79
- `Please update to Node 16 or higher for a better, fully supported experience.\n`,
80
- ),
77
+ `Please update to Node 16 or higher for a better, fully supported experience.\n`
78
+ )
81
79
  );
82
-
83
80
  // Fall back to latest supported react-scripts on Node 4
84
81
  return process.exit(1);
85
82
  }
86
-
87
83
  logger.write(' ✅ \n');
88
84
  }
89
85
 
@@ -105,10 +101,10 @@ function checkOptions(opts) {
105
101
  };
106
102
  }
107
103
 
108
- // eslint-disable-next-line no-unused-vars
109
104
  const printDeprecationNotice = (param) =>
110
105
  console.warn(
111
- chalk.bgYellowBright`DEPRECATED OPTION: ${param}` + ` Use ${chalk.cyan(`create-corva-app ${param} .`)} instead`,
106
+ chalk.bgYellowBright`DEPRECATED OPTION: ${param}` +
107
+ ` Use ${chalk.cyan(`create-corva-app ${param} .`)} instead`
112
108
  );
113
109
 
114
110
  export async function run() {
@@ -131,7 +127,9 @@ export async function run() {
131
127
  manifestConstants.manifestOptions().forEach((value) => {
132
128
  const type = typeof value.default;
133
129
  const option = new Option(
134
- `${value.alias ? `-${value.alias}, ` : ''}--${value.name} [${(type !== 'undefined' && type) || 'string'}]`,
130
+ `${value.alias ? `-${value.alias}, ` : ''}--${value.name} [${
131
+ (type !== 'undefined' && type) || 'string'
132
+ }]`,
135
133
  value.message,
136
134
  );
137
135
 
@@ -139,7 +137,9 @@ export async function run() {
139
137
  if (typeof value.choices === 'function') {
140
138
  option.choices(value.choices());
141
139
  } else {
142
- option.choices(value.choices.map((choice) => `${typeof choice === 'object' ? choice.value : choice}`));
140
+ option.choices(
141
+ value.choices.map((choice) => `${typeof choice === 'object' ? choice.value : choice}`)
142
+ );
143
143
  }
144
144
  }
145
145
 
@@ -180,14 +180,10 @@ export async function run() {
180
180
  silencer(async (dirName, patterns, options) => {
181
181
  options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
182
182
 
183
- console.log(getRealWorkingDir(dirName, options), options);
183
+ console.log(getRealWorkingDir(dirName, options), options)
184
184
 
185
- return runFlow(ZIP_FLOW, {
186
- dirName: getRealWorkingDir(dirName, options),
187
- patterns,
188
- options,
189
- }).then(_.get('zipFileName'));
190
- }),
185
+ return runFlow(ZIP_FLOW, { dirName: getRealWorkingDir(dirName, options), patterns, options }).then(_.get('zipFileName'));
186
+ })
191
187
  );
192
188
 
193
189
  program
@@ -202,20 +198,26 @@ export async function run() {
202
198
  .addOption(apiKeyOption)
203
199
  .addOption(originalCwdOption)
204
200
  .addOption(new Option('--notes [string]', 'Add custom notes to published app'))
205
- .addOption(new Option('--label [string]', 'Put a label on the release').choices(['BETA', 'PROD']))
206
- .addOption(new Option('--remove-on-fail [boolean]', 'Remove release if it fails during deployment').default(false))
207
201
  .addOption(
208
- new Option('--remove-on-success [boolean]', 'App package (.zip) will not be deleted after upload').default(true),
202
+ new Option('--label [string]', 'Put a label on the release').choices(['BETA', 'PROD'])
203
+ )
204
+ .addOption(
205
+ new Option(
206
+ '--remove-on-fail [boolean]',
207
+ 'Remove release if it fails during deployment'
208
+ ).default(false)
209
+ )
210
+ .addOption(
211
+ new Option(
212
+ '--remove-on-success [boolean]',
213
+ 'App package (.zip) will not be deleted after upload'
214
+ ).default(true)
209
215
  )
210
216
  // .addOption(new Option('--zip-file-name [string]', 'Prebuilt zip file name in dir'))
211
217
  .action(async (dirName, patterns, options) => {
212
218
  options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
213
219
 
214
- await runFlow(RELEASE_FLOW, {
215
- dirName: getRealWorkingDir(dirName, options),
216
- patterns,
217
- options,
218
- });
220
+ await runFlow(RELEASE_FLOW, { dirName: getRealWorkingDir(dirName, options), patterns, options });
219
221
  });
220
222
 
221
223
  program
@@ -283,12 +285,16 @@ const handleCommanderError = (e) => {
283
285
  const commandName = program.args[0] || program._defaultCommandName;
284
286
 
285
287
  console.error('Please specify the project directory:');
286
- logger.log(` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('<project-directory>')}`);
288
+ logger.log(
289
+ ` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('<project-directory>')}`
290
+ );
287
291
  logger.log();
288
292
  logger.log('For example:');
289
293
  logger.log(` ${chalk.cyan(program.name())} ${commandName} ${chalk.green('my-react-app')}`);
290
294
  logger.log();
291
- logger.log(`Run ${chalk.cyan(`${program.name()} help ${commandName}`)} to see all options.`);
295
+ logger.log(
296
+ `Run ${chalk.cyan(`${program.name()} help ${commandName}`)} to see all options.`
297
+ );
292
298
  } else {
293
299
  console.error('❌', e.message);
294
300
  }
@@ -333,8 +339,8 @@ async function initPackage(projectName, opts) {
333
339
  if (!(await runtime.isRuntimeAvailable())) {
334
340
  throw new Error(
335
341
  `Runtime "${opts.runtime}" is not available locally. Please proceed to ${chalk.green(
336
- getEnvManagementLink(manifest),
337
- )} to install it locally.`,
342
+ getEnvManagementLink(manifest)
343
+ )} to install it locally.`
338
344
  );
339
345
  }
340
346
 
@@ -349,7 +355,6 @@ async function initPackage(projectName, opts) {
349
355
  if (fs.existsSync(root)) {
350
356
  throw new Error(`Directory already exists: ${root}`);
351
357
  }
352
-
353
358
  await fs.mkdir(root);
354
359
  await fs.writeJSON(path.join(root, 'manifest.json'), manifest.manifest, writejsonOptions);
355
360
 
@@ -388,7 +393,13 @@ async function addTemplate(root, manifest, runtime) {
388
393
  logger.log(chalk.green('Copying app template...'));
389
394
  logger.log();
390
395
 
391
- const templateFolder = path.resolve(__dirname, '..', 'templates', runtime.language, manifest.type);
396
+ const templateFolder = path.resolve(
397
+ __dirname,
398
+ '..',
399
+ 'templates',
400
+ runtime.language,
401
+ manifest.type
402
+ );
392
403
 
393
404
  utils.copyFolderRecursiveSync(templateFolder, root);
394
405
 
@@ -451,7 +462,7 @@ const addTsConfigs = (root, manifest, runtime) => {
451
462
  inlineSourceMap: true,
452
463
  },
453
464
  },
454
- writejsonOptions,
465
+ writejsonOptions
455
466
  ),
456
467
  fs.writeJson(
457
468
  path.resolve(root, 'tsconfig.build.json'),
@@ -460,7 +471,7 @@ const addTsConfigs = (root, manifest, runtime) => {
460
471
  include: ['lib/**/*.ts', 'index.ts'],
461
472
  exclude: ['node_modules', '**/*.spec.ts'],
462
473
  },
463
- writejsonOptions,
474
+ writejsonOptions
464
475
  ),
465
476
  ]);
466
477
  };
@@ -472,7 +483,13 @@ function patchSchedulerForPython(root, manifest, runtime) {
472
483
  return;
473
484
  }
474
485
 
475
- const templateFolder = path.resolve(__dirname, '..', 'templates', runtime.language, manifest.type);
486
+ const templateFolder = path.resolve(
487
+ __dirname,
488
+ '..',
489
+ 'templates',
490
+ runtime.language,
491
+ manifest.type
492
+ );
476
493
  const originalType = 'ScheduledDataTimeEvent';
477
494
  const replacementType =
478
495
  schedulerType === manifestConstants.SCHEDULER_TYPE_DEPTH.value
@@ -527,7 +544,6 @@ async function installApp(root, manifest, runtime) {
527
544
  }
528
545
 
529
546
  logger.log(chalk.yellow(`Installing template dependencies using ${runtime.packageManager}...`));
530
-
531
547
  const proc =
532
548
  manifest.isJs() && existsSync(`${os.homedir()}/.nvm/nvm.sh`)
533
549
  ? spawn.sync(`\\. ${os.homedir()}/.nvm/nvm.sh && nvm i && ${command} ${args.join(' ')}`, {
@@ -543,13 +559,11 @@ async function installApp(root, manifest, runtime) {
543
559
  // NOTE: filter out warnings caused by @corva/ui peer dependencies
544
560
  .filter((line) => !line.includes('@corva/ui'))
545
561
  .join('\n');
546
-
547
562
  console.log(error);
548
563
  }
549
564
 
550
565
  if (proc.status !== 0) {
551
566
  console.error(`\`${command} ${args.join(' ')}\` failed`);
552
-
553
567
  return;
554
568
  }
555
569
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.44.0-2",
3
+ "version": "0.44.0",
4
4
  "private": false,
5
5
  "description": "Create an app to use it in CORVA.AI",
6
6
  "keywords": [