@corva/create-app 0.0.0-2576df8
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/README.md +218 -0
- package/bin/cca.js +5 -0
- package/bin/create-corva-app.cjs +25 -0
- package/common/node/.env +15 -0
- package/common/node/.env.sample +26 -0
- package/common/node/gitignore +130 -0
- package/common/package.json +3 -0
- package/common/python/.env +5 -0
- package/common/python/.env.sample +7 -0
- package/common/python/Makefile +15 -0
- package/common/python/gitignore +161 -0
- package/common/python/requirements.txt +2 -0
- package/lib/commands/attach.js +28 -0
- package/lib/commands/create.js +463 -0
- package/lib/commands/release.js +58 -0
- package/lib/commands/rerun.js +34 -0
- package/lib/commands/zip.js +39 -0
- package/lib/constants/cache.js +5 -0
- package/lib/constants/cli.js +35 -0
- package/lib/constants/manifest.js +263 -0
- package/lib/constants/messages.js +15 -0
- package/lib/constants/package.js +288 -0
- package/lib/flow.js +53 -0
- package/lib/flows/attach.js +8 -0
- package/lib/flows/lib/api.js +385 -0
- package/lib/flows/lib/create-zip-archive.js +83 -0
- package/lib/flows/lib/json.js +30 -0
- package/lib/flows/lib/manifest.js +81 -0
- package/lib/flows/lib/notification.js +142 -0
- package/lib/flows/lib/step-error.js +10 -0
- package/lib/flows/lib/waitForMs.js +3 -0
- package/lib/flows/prepare.js +6 -0
- package/lib/flows/release.js +26 -0
- package/lib/flows/rerun.js +8 -0
- package/lib/flows/steps/attach/add-app-to-stream.js +23 -0
- package/lib/flows/steps/attach/get-all-live-assets.js +135 -0
- package/lib/flows/steps/attach/index.js +5 -0
- package/lib/flows/steps/attach/prepare-data.js +19 -0
- package/lib/flows/steps/prepare-load-app-files.js +12 -0
- package/lib/flows/steps/release/add-label.js +10 -0
- package/lib/flows/steps/release/add-notes.js +10 -0
- package/lib/flows/steps/release/get-config.js +41 -0
- package/lib/flows/steps/release/prepare-data.js +12 -0
- package/lib/flows/steps/release/publish.js +11 -0
- package/lib/flows/steps/release/remove-failed-upload.js +21 -0
- package/lib/flows/steps/release/upload-zip-to-corva.js +136 -0
- package/lib/flows/steps/release/wait-for-build.js +36 -0
- package/lib/flows/steps/rerun/create-task.js +77 -0
- package/lib/flows/steps/rerun/ensure-that-app-in-stream.js +68 -0
- package/lib/flows/steps/rerun/get-app-version.js +111 -0
- package/lib/flows/steps/rerun/prepare-data.js +162 -0
- package/lib/flows/steps/rerun/prepare-well-and-stream-data.js +188 -0
- package/lib/flows/steps/rerun/rerun.js +13 -0
- package/lib/flows/steps/zip-cleanup.js +17 -0
- package/lib/flows/steps/zip-create-archive.js +15 -0
- package/lib/flows/steps/zip-file-list-resolve.js +266 -0
- package/lib/flows/steps/zip-prepare.js +20 -0
- package/lib/flows/steps/zip.js +6 -0
- package/lib/flows/zip-simple.js +6 -0
- package/lib/flows/zip.js +7 -0
- package/lib/helpers/cli-version.js +150 -0
- package/lib/helpers/commands.js +13 -0
- package/lib/helpers/logger.js +35 -0
- package/lib/helpers/manifest.js +82 -0
- package/lib/helpers/resolve-app-runtime.js +132 -0
- package/lib/helpers/utils.js +97 -0
- package/lib/helpers/versioning.js +94 -0
- package/lib/main.js +64 -0
- package/lib/options/api-key.js +6 -0
- package/lib/options/app-key.js +6 -0
- package/lib/options/app-version.js +3 -0
- package/lib/options/bump-version.js +19 -0
- package/lib/options/cache.js +11 -0
- package/lib/options/env.js +3 -0
- package/lib/options/original-cwd.js +3 -0
- package/lib/options/silent.js +3 -0
- package/package.json +1 -0
- package/template_extensions/corva/.commitlintrc.json +6 -0
- package/template_extensions/corva/.eslintrc +32 -0
- package/template_extensions/corva/.github/pull_request_template.md +14 -0
- package/template_extensions/corva/.github/workflows/code-checks.yml +15 -0
- package/template_extensions/corva/.github/workflows/develop.yml +19 -0
- package/template_extensions/corva/.github/workflows/feat-fix-delete.yml +14 -0
- package/template_extensions/corva/.github/workflows/feat-fix.yml +23 -0
- package/template_extensions/corva/.github/workflows/release-fix-X.X.X.yml +16 -0
- package/template_extensions/corva/.github/workflows/validate-pr-title.yml +19 -0
- package/template_extensions/corva/.husky/commit-msg +5 -0
- package/template_extensions/corva/.husky/pre-commit +4 -0
- package/template_extensions/corva/.release-please-manifest.json +3 -0
- package/template_extensions/corva/release-please-config.json +10 -0
- package/templates/scheduler_data-time/javascript/README.md +19 -0
- package/templates/scheduler_data-time/javascript/__tests__/processor.spec.js +15 -0
- package/templates/scheduler_data-time/javascript/index.js +15 -0
- package/templates/scheduler_data-time/python/README.md +31 -0
- package/templates/scheduler_data-time/python/lambda_function.py +7 -0
- package/templates/scheduler_data-time/python/test/__init__.py +0 -0
- package/templates/scheduler_data-time/python/test/app_test.py +10 -0
- package/templates/scheduler_data-time/typescript/README.md +25 -0
- package/templates/scheduler_data-time/typescript/__tests__/processor.spec.ts +15 -0
- package/templates/scheduler_data-time/typescript/index.ts +8 -0
- package/templates/scheduler_depth/javascript/README.md +19 -0
- package/templates/scheduler_depth/javascript/__tests__/processor.spec.js +17 -0
- package/templates/scheduler_depth/javascript/index.js +15 -0
- package/templates/scheduler_depth/python/README.md +31 -0
- package/templates/scheduler_depth/python/lambda_function.py +7 -0
- package/templates/scheduler_depth/python/test/__init__.py +0 -0
- package/templates/scheduler_depth/python/test/app_test.py +10 -0
- package/templates/scheduler_depth/typescript/README.md +25 -0
- package/templates/scheduler_depth/typescript/__tests__/processor.spec.ts +17 -0
- package/templates/scheduler_depth/typescript/index.ts +8 -0
- package/templates/scheduler_natural-time/javascript/README.md +19 -0
- package/templates/scheduler_natural-time/javascript/__tests__/processor.spec.js +15 -0
- package/templates/scheduler_natural-time/javascript/index.js +15 -0
- package/templates/scheduler_natural-time/python/README.md +31 -0
- package/templates/scheduler_natural-time/python/lambda_function.py +7 -0
- package/templates/scheduler_natural-time/python/test/__init__.py +0 -0
- package/templates/scheduler_natural-time/python/test/app_test.py +10 -0
- package/templates/scheduler_natural-time/typescript/README.md +25 -0
- package/templates/scheduler_natural-time/typescript/__tests__/processor.spec.ts +15 -0
- package/templates/scheduler_natural-time/typescript/index.ts +8 -0
- package/templates/stream_depth/javascript/README.md +19 -0
- package/templates/stream_depth/javascript/__tests__/processor.spec.js +20 -0
- package/templates/stream_depth/javascript/index.js +14 -0
- package/templates/stream_depth/python/README.md +31 -0
- package/templates/stream_depth/python/lambda_function.py +7 -0
- package/templates/stream_depth/python/test/__init__.py +0 -0
- package/templates/stream_depth/python/test/app_test.py +16 -0
- package/templates/stream_depth/typescript/README.md +25 -0
- package/templates/stream_depth/typescript/__tests__/processor.spec.ts +20 -0
- package/templates/stream_depth/typescript/index.ts +8 -0
- package/templates/stream_time/javascript/README.md +19 -0
- package/templates/stream_time/javascript/__tests__/processor.spec.js +14 -0
- package/templates/stream_time/javascript/index.js +14 -0
- package/templates/stream_time/python/README.md +31 -0
- package/templates/stream_time/python/lambda_function.py +7 -0
- package/templates/stream_time/python/test/__init__.py +0 -0
- package/templates/stream_time/python/test/app_test.py +16 -0
- package/templates/stream_time/typescript/README.md +25 -0
- package/templates/stream_time/typescript/__tests__/processor.spec.ts +14 -0
- package/templates/stream_time/typescript/index.ts +8 -0
- package/templates/task/javascript/README.md +19 -0
- package/templates/task/javascript/__tests__/processor.spec.js +16 -0
- package/templates/task/javascript/index.js +15 -0
- package/templates/task/python/README.md +31 -0
- package/templates/task/python/lambda_function.py +7 -0
- package/templates/task/python/test/__init__.py +0 -0
- package/templates/task/python/test/app_test.py +8 -0
- package/templates/task/typescript/README.md +25 -0
- package/templates/task/typescript/__tests__/processor.spec.ts +16 -0
- package/templates/task/typescript/index.ts +8 -0
- package/templates/ui/javascript/.codex/config.toml +3 -0
- package/templates/ui/javascript/.cursor/mcp.json +8 -0
- package/templates/ui/javascript/.eslintrc +11 -0
- package/templates/ui/javascript/.mcp.json +8 -0
- package/templates/ui/javascript/.prettierrc +1 -0
- package/templates/ui/javascript/AGENTS.md +304 -0
- package/templates/ui/javascript/CLAUDE.md +1 -0
- package/templates/ui/javascript/README.md +31 -0
- package/templates/ui/javascript/config/jest/babelTransform.js +16 -0
- package/templates/ui/javascript/config/jest/cssTransform.js +16 -0
- package/templates/ui/javascript/config/jest/fileTransform.js +48 -0
- package/templates/ui/javascript/config/jest/globalSetup.js +5 -0
- package/templates/ui/javascript/config/jest/setupTests.js +30 -0
- package/templates/ui/javascript/config-overrides.js +10 -0
- package/templates/ui/javascript/gitignore +27 -0
- package/templates/ui/javascript/src/App.completion.js +52 -0
- package/templates/ui/javascript/src/App.drilling.js +49 -0
- package/templates/ui/javascript/src/App.scss +17 -0
- package/templates/ui/javascript/src/AppSettings.js +28 -0
- package/templates/ui/javascript/src/__tests__/App.test.js +26 -0
- package/templates/ui/javascript/src/__tests__/AppSettings.test.js +28 -0
- package/templates/ui/javascript/src/__tests__/TestsExample.test.js +37 -0
- package/templates/ui/javascript/src/assets/logo.svg +7 -0
- package/templates/ui/javascript/src/constants.js +3 -0
- package/templates/ui/javascript/src/index.js +8 -0
- package/templates/ui/typescript/.codex/config.toml +3 -0
- package/templates/ui/typescript/.cursor/mcp.json +8 -0
- package/templates/ui/typescript/.eslintrc +28 -0
- package/templates/ui/typescript/.mcp.json +8 -0
- package/templates/ui/typescript/.prettierrc +1 -0
- package/templates/ui/typescript/AGENTS.md +344 -0
- package/templates/ui/typescript/CLAUDE.md +1 -0
- package/templates/ui/typescript/README.md +31 -0
- package/templates/ui/typescript/config/jest/babelTransform.js +16 -0
- package/templates/ui/typescript/config/jest/cssTransform.js +16 -0
- package/templates/ui/typescript/config/jest/fileTransform.js +48 -0
- package/templates/ui/typescript/config/jest/globalSetup.js +5 -0
- package/templates/ui/typescript/config/jest/setupTests.js +30 -0
- package/templates/ui/typescript/config-overrides.js +10 -0
- package/templates/ui/typescript/gitignore +27 -0
- package/templates/ui/typescript/src/App.completion.tsx +52 -0
- package/templates/ui/typescript/src/App.drilling.tsx +49 -0
- package/templates/ui/typescript/src/App.scss +17 -0
- package/templates/ui/typescript/src/AppSettings.tsx +28 -0
- package/templates/ui/typescript/src/__mocks__/mockData.ts +22 -0
- package/templates/ui/typescript/src/__tests__/App.test.tsx +27 -0
- package/templates/ui/typescript/src/__tests__/AppSettings.test.tsx +28 -0
- package/templates/ui/typescript/src/__tests__/TestsExample.test.tsx +37 -0
- package/templates/ui/typescript/src/assets/logo.svg +7 -0
- package/templates/ui/typescript/src/constants.ts +3 -0
- package/templates/ui/typescript/src/custom.d.ts +19 -0
- package/templates/ui/typescript/src/index.js +8 -0
- package/templates/ui/typescript/src/types.ts +3 -0
- package/templates/ui/typescript/tsconfig.json +7 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import Glob from 'glob';
|
|
3
|
+
import isGlob from 'is-glob';
|
|
4
|
+
import _ from 'lodash/fp.js';
|
|
5
|
+
import { promises as fs } from 'node:fs';
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
import { promisify } from 'node:util';
|
|
8
|
+
import { getIncreasedVersion } from '../../helpers/cli-version.js';
|
|
9
|
+
import { generateRandomString } from '../../helpers/utils.js';
|
|
10
|
+
import { loadJson } from '../lib/json.js';
|
|
11
|
+
import { StepError } from '../lib/step-error.js';
|
|
12
|
+
|
|
13
|
+
const glob = promisify(Glob);
|
|
14
|
+
|
|
15
|
+
import debugFn from 'debug';
|
|
16
|
+
|
|
17
|
+
const debug = debugFn('cca:flow:zip:resolve');
|
|
18
|
+
|
|
19
|
+
const uniqueValues = (array) => Array.from(new Set(array));
|
|
20
|
+
|
|
21
|
+
export const FILE_LIST_RESOLVE_STEP = {
|
|
22
|
+
message: 'Resolving files list...',
|
|
23
|
+
fn: async (context) => {
|
|
24
|
+
const { patterns, manifest, dirName, options } = context;
|
|
25
|
+
const files = await transformPatternsIntoFileNames(dirName, patterns, options.ignoredFiles);
|
|
26
|
+
|
|
27
|
+
if (manifest.isUi()) {
|
|
28
|
+
return resolveDataToZipUiApp(files, context);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (manifest.isNode()) {
|
|
32
|
+
return resolveDataForZipNodeJsApp(files, context);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (manifest.isPython()) {
|
|
36
|
+
return resolveDataForZipPythonApp(files, context);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
throw new StepError(`Unsupported runtime: ${manifest.runtime}`);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const transformPatternsIntoFileNames = async (dirName, patterns, ignoredFiles = []) => {
|
|
44
|
+
const filesFromPatterns = [];
|
|
45
|
+
|
|
46
|
+
for (const pattern of patterns) {
|
|
47
|
+
if (pattern.includes('node_modules')) {
|
|
48
|
+
debug('Invalid file pattern', pattern);
|
|
49
|
+
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!isGlob(pattern, { strict: false })) {
|
|
54
|
+
filesFromPatterns.push(pattern);
|
|
55
|
+
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const files = await glob(pattern, {
|
|
60
|
+
cwd: dirName,
|
|
61
|
+
ignore: ['**/node_modules', ...ignoredFiles],
|
|
62
|
+
nodir: true,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
filesFromPatterns.push(...files);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return filesFromPatterns;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param {string[]} itemsToZip
|
|
74
|
+
* @param {object} param1
|
|
75
|
+
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
const resolveDataToZipUiApp = async (itemsToZip = [], { options, pkg, dirName, manifest, appKey }) => {
|
|
79
|
+
const version = await getIncreasedVersion(pkg.version, options);
|
|
80
|
+
const randomSuffix = generateRandomString(); // Random suffix is needed to not cause a conflict when we call 2 parallel commands at the same time.
|
|
81
|
+
const zipFileName = `${manifest.unix_name}-${version}-${randomSuffix}.zip`;
|
|
82
|
+
const itemsToSave = [];
|
|
83
|
+
const shouldUpdateVersion = version !== pkg.version;
|
|
84
|
+
|
|
85
|
+
if (shouldUpdateVersion) {
|
|
86
|
+
pkg.version = version;
|
|
87
|
+
|
|
88
|
+
itemsToSave.push({
|
|
89
|
+
name: 'package.json',
|
|
90
|
+
content: pkg,
|
|
91
|
+
message: chalk(
|
|
92
|
+
`\n${chalk.yellow`NOTE`}: Version of your app was updated to ${version} (package.json), please don't lower it.`,
|
|
93
|
+
),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const tmpPackageForSourceName = `packageForSource_${randomSuffix}.json`;
|
|
98
|
+
|
|
99
|
+
itemsToSave.push({
|
|
100
|
+
name: tmpPackageForSourceName,
|
|
101
|
+
content: {
|
|
102
|
+
...pkg,
|
|
103
|
+
scripts: {
|
|
104
|
+
build: pkg.scripts?.build,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const itemsToRemove = [tmpPackageForSourceName];
|
|
110
|
+
|
|
111
|
+
itemsToZip.push(
|
|
112
|
+
'manifest.json',
|
|
113
|
+
'config-overrides.js',
|
|
114
|
+
'eslint.config.js',
|
|
115
|
+
'eslint.config.mjs',
|
|
116
|
+
'tsconfig.json',
|
|
117
|
+
'prettier.config.js',
|
|
118
|
+
'.prettierrc',
|
|
119
|
+
'.npmrc',
|
|
120
|
+
'.nvmrc',
|
|
121
|
+
'yarn.lock',
|
|
122
|
+
{
|
|
123
|
+
path: resolve(dirName, tmpPackageForSourceName),
|
|
124
|
+
name: 'package.json',
|
|
125
|
+
},
|
|
126
|
+
...(await transformPatternsIntoFileNames(dirName, ['src/**/*'], options.ignoredFiles)),
|
|
127
|
+
...(await transformPatternsIntoFileNames(dirName, ['config/**/*'], options.ignoredFiles)),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
if (options.appKey) {
|
|
131
|
+
/**
|
|
132
|
+
* Both manifest.json appKey in zip and the provided
|
|
133
|
+
* appKey param should match. That's why we set it for cases when appKey option
|
|
134
|
+
* is specified to override the one from manifest.json
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
const tmpManifestForSourceName = `manifestForSource_${randomSuffix}.json`;
|
|
138
|
+
|
|
139
|
+
itemsToSave.push({
|
|
140
|
+
name: tmpManifestForSourceName,
|
|
141
|
+
content: _.set('application.key', appKey, manifest.manifest),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
itemsToRemove.push(tmpManifestForSourceName);
|
|
145
|
+
|
|
146
|
+
itemsToZip.push({
|
|
147
|
+
path: resolve(dirName, tmpManifestForSourceName),
|
|
148
|
+
name: 'manifest.json',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
zipFileName,
|
|
154
|
+
itemsToZip,
|
|
155
|
+
itemsToSave,
|
|
156
|
+
itemsToRemove,
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
*
|
|
162
|
+
* @param {string[]} itemsToZip
|
|
163
|
+
* @param {object} param1
|
|
164
|
+
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
165
|
+
* @returns
|
|
166
|
+
*/
|
|
167
|
+
const resolveDataForZipNodeJsApp = async (itemsToZip = [], { options, pkg, dirName, manifest }) => {
|
|
168
|
+
const version = await getIncreasedVersion(pkg.version, options);
|
|
169
|
+
const zipFileName = `${manifest.unix_name}-${version}.zip`;
|
|
170
|
+
const itemsToSave = [];
|
|
171
|
+
const shouldUpdateVersion = version !== pkg.version;
|
|
172
|
+
|
|
173
|
+
if (shouldUpdateVersion) {
|
|
174
|
+
pkg.version = version;
|
|
175
|
+
|
|
176
|
+
itemsToSave.push({
|
|
177
|
+
name: 'package.json',
|
|
178
|
+
content: pkg,
|
|
179
|
+
message: chalk(
|
|
180
|
+
`\n${chalk.yellow`NOTE`}: Version of your app was updated to ${version} (package.json), please don't lower it.`,
|
|
181
|
+
),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const packageDirContent = await fs.readdir(dirName);
|
|
186
|
+
const shouldPushDefaultSrc = !itemsToZip.length;
|
|
187
|
+
|
|
188
|
+
itemsToZip.push('config', 'manifest.json', 'package.json', '.nvmrc', '.npmrc', '.eslintrc.js');
|
|
189
|
+
|
|
190
|
+
if (packageDirContent.includes('pnpm-lock.yaml')) {
|
|
191
|
+
itemsToZip.push('pnpm-lock.yaml');
|
|
192
|
+
} else if (packageDirContent.includes('package-lock.json')) {
|
|
193
|
+
itemsToZip.push('package-lock.json');
|
|
194
|
+
|
|
195
|
+
if (shouldUpdateVersion) {
|
|
196
|
+
itemsToSave.push({
|
|
197
|
+
name: 'package-lock.json',
|
|
198
|
+
content: _.set('version', version, await loadJson(dirName, 'package-lock.json')),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
} else if (packageDirContent.includes('yarn.lock')) {
|
|
202
|
+
itemsToZip.push('yarn.lock');
|
|
203
|
+
} else {
|
|
204
|
+
throw new StepError(`No lock file found in ${dirName}`);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const defaultSrcWithoutExtensions = '+(__tests__|src|lib)/**/*.';
|
|
208
|
+
|
|
209
|
+
if (packageDirContent.includes('tsconfig.json')) {
|
|
210
|
+
itemsToZip.push('tsconfig.json', 'tsconfig.build.json');
|
|
211
|
+
|
|
212
|
+
if (shouldPushDefaultSrc) {
|
|
213
|
+
itemsToZip.push(
|
|
214
|
+
'index.ts',
|
|
215
|
+
...(await glob(`${defaultSrcWithoutExtensions}ts`, {
|
|
216
|
+
cwd: dirName,
|
|
217
|
+
ignore: options.ignoredFiles,
|
|
218
|
+
})),
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
} else if (shouldPushDefaultSrc) {
|
|
222
|
+
itemsToZip.push(
|
|
223
|
+
'index.js',
|
|
224
|
+
...(await glob(`${defaultSrcWithoutExtensions}js`, {
|
|
225
|
+
cwd: dirName,
|
|
226
|
+
ignore: options.ignoredFiles,
|
|
227
|
+
})),
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
zipFileName,
|
|
233
|
+
itemsToZip: uniqueValues(itemsToZip),
|
|
234
|
+
itemsToSave,
|
|
235
|
+
itemsToRemove: [],
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
*
|
|
241
|
+
* @param {string[]} itemsToZip
|
|
242
|
+
* @param {object} param1
|
|
243
|
+
* @param {import('../lib/manifest').Manifest} param1.manifest
|
|
244
|
+
* @returns
|
|
245
|
+
*/
|
|
246
|
+
const resolveDataForZipPythonApp = async (itemsToZip = [], { manifest, dirName, options }) => {
|
|
247
|
+
const zipFileName = `${manifest.unix_name}.zip`;
|
|
248
|
+
|
|
249
|
+
if (!itemsToZip.length) {
|
|
250
|
+
itemsToZip.push(
|
|
251
|
+
...(await glob('**/*.py', {
|
|
252
|
+
cwd: dirName,
|
|
253
|
+
ignore: [...(options.ignoredFiles || []), 'venv/**/*'],
|
|
254
|
+
})),
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
itemsToZip.push('manifest.json', 'requirements.txt');
|
|
259
|
+
|
|
260
|
+
return {
|
|
261
|
+
zipFileName,
|
|
262
|
+
itemsToZip: uniqueValues(itemsToZip),
|
|
263
|
+
itemsToSave: [],
|
|
264
|
+
itemsToRemove: [],
|
|
265
|
+
};
|
|
266
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { logger } from '../../helpers/logger.js';
|
|
2
|
+
import { saveJson } from '../lib/json.js';
|
|
3
|
+
|
|
4
|
+
import debugFn from 'debug';
|
|
5
|
+
|
|
6
|
+
const debug = debugFn('cca:flow:zip:prepare');
|
|
7
|
+
|
|
8
|
+
export const PREPARE_FILES_BEFORE_ZIP_STEP = {
|
|
9
|
+
message: 'Preparing...',
|
|
10
|
+
fn: async ({ itemsToSave, dirName }) => {
|
|
11
|
+
for (const item of itemsToSave) {
|
|
12
|
+
debug(`Updating %s`, item.name);
|
|
13
|
+
await saveJson(dirName, item.name, item.content);
|
|
14
|
+
|
|
15
|
+
if (item.message) {
|
|
16
|
+
logger.write(item.message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CLEANUP_STEP } from './zip-cleanup.js';
|
|
2
|
+
import { CREATE_ARCHIVE_STEP } from './zip-create-archive.js';
|
|
3
|
+
import { FILE_LIST_RESOLVE_STEP } from './zip-file-list-resolve.js';
|
|
4
|
+
import { PREPARE_FILES_BEFORE_ZIP_STEP } from './zip-prepare.js';
|
|
5
|
+
|
|
6
|
+
export const ZIP_STEPS = [FILE_LIST_RESOLVE_STEP, PREPARE_FILES_BEFORE_ZIP_STEP, CREATE_ARCHIVE_STEP, CLEANUP_STEP];
|
package/lib/flows/zip.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import NpmApi from 'npm-api';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
import * as url from 'url';
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
|
|
9
|
+
import { logger } from './logger.js';
|
|
10
|
+
import { StepError } from '../flows/lib/step-error.js';
|
|
11
|
+
|
|
12
|
+
const npm = new NpmApi();
|
|
13
|
+
|
|
14
|
+
const error = chalk.bold.red;
|
|
15
|
+
const warning = chalk.hex('#FFA500'); // Orange
|
|
16
|
+
const code = chalk.cyan;
|
|
17
|
+
const asterisks = '****************************************************************';
|
|
18
|
+
|
|
19
|
+
const getCurrentVersion = async () =>
|
|
20
|
+
(await fs.readJSON(join(url.fileURLToPath(new URL('.', import.meta.url)), '../../package.json'))).version;
|
|
21
|
+
|
|
22
|
+
const getLatestVersion = async () => {
|
|
23
|
+
try {
|
|
24
|
+
return await npm.repo('@corva/create-app').prop('version');
|
|
25
|
+
} catch (caughtError) {
|
|
26
|
+
if (caughtError.name === 'FetchError') {
|
|
27
|
+
throw new StepError(`The request to check the latest available version has failed due to the network error. Details:
|
|
28
|
+
|
|
29
|
+
${caughtError}
|
|
30
|
+
|
|
31
|
+
Please check your internet connection and that the above request is not blocked in your network
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
throw caughtError;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Utility function to check if a version is a regular semver without prerelease identifiers
|
|
40
|
+
const isRegularVersion = (version) => {
|
|
41
|
+
return semver.prerelease(version) === null;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// NOTE: Stop process and show error if version is outdated
|
|
45
|
+
export async function ensureLatestVersion() {
|
|
46
|
+
const currentVersion = await getCurrentVersion();
|
|
47
|
+
const latestVersion = await getLatestVersion();
|
|
48
|
+
|
|
49
|
+
// Skip version check if current version is a prerelease (dev or next)
|
|
50
|
+
if (!isRegularVersion(currentVersion)) {
|
|
51
|
+
logger.write('Skipping version check for prerelease version.\n');
|
|
52
|
+
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const isCurrentVersionOutdated = semver.gt(latestVersion, currentVersion);
|
|
57
|
+
|
|
58
|
+
if (isCurrentVersionOutdated) {
|
|
59
|
+
console.log(error(asterisks));
|
|
60
|
+
console.log(error`
|
|
61
|
+
Your version of the @corva/create-app is outdated.
|
|
62
|
+
There is a new version available ({green.bold ${latestVersion}}).
|
|
63
|
+
Please update the @corva/create-app with the following command:
|
|
64
|
+
|
|
65
|
+
${code('npm i -g @corva/create-app@latest')}
|
|
66
|
+
|
|
67
|
+
`);
|
|
68
|
+
console.log(error(asterisks));
|
|
69
|
+
process.exit(0);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// NOTE: Show user-friendly warning if version is outdated
|
|
74
|
+
export async function warnIfOutdated() {
|
|
75
|
+
logger.write('Checking for updates...\n');
|
|
76
|
+
|
|
77
|
+
const currentVersion = await getCurrentVersion();
|
|
78
|
+
const latestVersion = await getLatestVersion();
|
|
79
|
+
|
|
80
|
+
// Skip version check if current version is a prerelease (dev or next)
|
|
81
|
+
if (!isRegularVersion(currentVersion)) {
|
|
82
|
+
logger.write(' ⚠️ Skipping version check for prerelease version.\n');
|
|
83
|
+
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const isCurrentVersionOutdated = semver.gt(latestVersion, currentVersion);
|
|
88
|
+
|
|
89
|
+
if (isCurrentVersionOutdated) {
|
|
90
|
+
console.log(warning(asterisks));
|
|
91
|
+
console.log(warning`
|
|
92
|
+
There is a new version available ({green.bold ${latestVersion}}).
|
|
93
|
+
You can update the CLI version with the following command:
|
|
94
|
+
|
|
95
|
+
${code`npm i -g @corva/create-app@latest`}
|
|
96
|
+
|
|
97
|
+
`);
|
|
98
|
+
console.log(warning(asterisks));
|
|
99
|
+
} else {
|
|
100
|
+
logger.write(' ✅ \n');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const PROMPT_MESSAGE = `Bumping package version:
|
|
105
|
+
${chalk.bold` Please select one of the options below:`}
|
|
106
|
+
`;
|
|
107
|
+
|
|
108
|
+
export const ensureBumpVersion = async (bumpVersion) => {
|
|
109
|
+
if (bumpVersion) {
|
|
110
|
+
return bumpVersion;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const { option, custom } = await inquirer.prompt([
|
|
114
|
+
{
|
|
115
|
+
message: PROMPT_MESSAGE,
|
|
116
|
+
name: 'option',
|
|
117
|
+
type: 'list',
|
|
118
|
+
choices: [
|
|
119
|
+
{ value: 'major', name: 'major (x+1.y.z)' },
|
|
120
|
+
{ value: 'minor', name: 'minor (x.y+1.z)' },
|
|
121
|
+
{ value: 'patch', name: 'patch (x.y.z+1)' },
|
|
122
|
+
new inquirer.Separator(),
|
|
123
|
+
{ value: 'custom', name: 'Enter a custom version' },
|
|
124
|
+
{ value: 'skip', name: 'Skip version bump' },
|
|
125
|
+
],
|
|
126
|
+
default: 'patch',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
message: 'Enter custom version',
|
|
130
|
+
name: 'custom',
|
|
131
|
+
when: (answers) => answers.option === 'custom',
|
|
132
|
+
type: 'input',
|
|
133
|
+
validate: (input) => (semver.valid(input) ? true : 'Invalid semver version'),
|
|
134
|
+
},
|
|
135
|
+
]);
|
|
136
|
+
|
|
137
|
+
return option === 'custom' ? custom : option;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export async function getIncreasedVersion(version, { bumpVersion: releaseTypeOrNewVersion }) {
|
|
141
|
+
if (releaseTypeOrNewVersion === 'skip') {
|
|
142
|
+
return version;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (semver.valid(releaseTypeOrNewVersion)) {
|
|
146
|
+
return releaseTypeOrNewVersion;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return semver.inc(version, releaseTypeOrNewVersion);
|
|
150
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
|
|
3
|
+
export const silencer =
|
|
4
|
+
(handler) =>
|
|
5
|
+
async (...args) => {
|
|
6
|
+
const result = await handler(...args);
|
|
7
|
+
|
|
8
|
+
if (args[args.length - 2].silent && result) {
|
|
9
|
+
console.log(result);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const getRealWorkingDir = (relativePath, options) => resolve(options.originalCwd, relativePath);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export class Logger {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.isSilent = process.argv.includes('--silent');
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
write(str) {
|
|
7
|
+
if (this.isSilent) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (str === undefined) {
|
|
12
|
+
process.stdout.write();
|
|
13
|
+
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
process.stdout.write(str);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
log(str) {
|
|
21
|
+
if (this.isSilent) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (str === undefined) {
|
|
26
|
+
console.log();
|
|
27
|
+
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log(str);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const logger = new Logger();
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { APP_EXTENSIONS, APP_RUNTIMES, APP_TYPES, TEMPLATE_TYPES } from '../constants/cli.js';
|
|
2
|
+
import * as manifestConstants from '../constants/manifest.js';
|
|
3
|
+
|
|
4
|
+
export function fillManifest(answers) {
|
|
5
|
+
const runtime = answers.runtime || APP_RUNTIMES.UI;
|
|
6
|
+
|
|
7
|
+
const defaultManifestProperties = _defaultManifestProperties({
|
|
8
|
+
type: answers.appType,
|
|
9
|
+
// fallback to UI
|
|
10
|
+
runtime,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const enable_isolation =
|
|
14
|
+
answers.appType === APP_TYPES.UI &&
|
|
15
|
+
answers.runtime === APP_RUNTIMES.UI &&
|
|
16
|
+
answers.extensions.includes(APP_EXTENSIONS.CORVA)
|
|
17
|
+
? false
|
|
18
|
+
: undefined;
|
|
19
|
+
|
|
20
|
+
const manifest = {
|
|
21
|
+
...manifestConstants.defaultManifest,
|
|
22
|
+
...defaultManifestProperties,
|
|
23
|
+
developer: {
|
|
24
|
+
...manifestConstants.defaultManifest.developer,
|
|
25
|
+
...defaultManifestProperties.developer,
|
|
26
|
+
name: answers.developerName,
|
|
27
|
+
identifier: answers.developerIdentifier,
|
|
28
|
+
},
|
|
29
|
+
application: {
|
|
30
|
+
...manifestConstants.defaultManifest.application,
|
|
31
|
+
...defaultManifestProperties.application,
|
|
32
|
+
key: answers.appKey,
|
|
33
|
+
name: answers.appName,
|
|
34
|
+
type: answers.appType,
|
|
35
|
+
description: answers.description,
|
|
36
|
+
summary: answers.summary,
|
|
37
|
+
category: answers.category,
|
|
38
|
+
website: answers.website,
|
|
39
|
+
segments: [answers.segments],
|
|
40
|
+
},
|
|
41
|
+
settings: {
|
|
42
|
+
...defaultManifestProperties.settings,
|
|
43
|
+
runtime,
|
|
44
|
+
app: defaultAppSettings(answers),
|
|
45
|
+
enable_isolation,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return manifest;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function _defaultManifestProperties({ type, runtime }) {
|
|
53
|
+
if (type === APP_TYPES.UI) {
|
|
54
|
+
return manifestConstants.defaultUIAppManifest;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (runtime.startsWith(TEMPLATE_TYPES.PYTHON)) {
|
|
58
|
+
return manifestConstants.defaultDataAppPythonManifest;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return manifestConstants.defaultDataAppNodeManifest;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function defaultAppSettings({ appType, schedulerType, cronString, depthMilestone, logType }) {
|
|
65
|
+
if (!schedulerType || appType !== APP_TYPES.SCHEDULER) {
|
|
66
|
+
return {
|
|
67
|
+
log_type: logType,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (schedulerType === manifestConstants.SCHEDULER_TYPE_DEPTH.value) {
|
|
72
|
+
return {
|
|
73
|
+
scheduler_type: schedulerType,
|
|
74
|
+
depth_milestone: depthMilestone || 1,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
scheduler_type: schedulerType,
|
|
80
|
+
cron_string: cronString || '*/5 * * * *',
|
|
81
|
+
};
|
|
82
|
+
}
|