@celljs/cli 3.7.7 → 3.8.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.
- package/lib/build/build-manager.d.ts.map +1 -1
- package/lib/build/build-manager.js.map +1 -1
- package/lib/build/build.d.ts +1 -1
- package/lib/build/build.d.ts.map +1 -1
- package/lib/build/build.js.map +1 -1
- package/lib/cell.js +8 -5
- package/lib/cell.js.map +1 -1
- package/lib/config/config.d.ts +1 -1
- package/lib/config/config.d.ts.map +1 -1
- package/lib/config/config.js.map +1 -1
- package/lib/deploy/deploy.d.ts +1 -1
- package/lib/deploy/deploy.d.ts.map +1 -1
- package/lib/deploy/deploy.js +4 -1
- package/lib/deploy/deploy.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/info/info.d.ts +1 -1
- package/lib/info/info.d.ts.map +1 -1
- package/lib/info/info.js.map +1 -1
- package/lib/init/init-manager.d.ts.map +1 -1
- package/lib/init/init-manager.js +5 -2
- package/lib/init/init-manager.js.map +1 -1
- package/lib/init/init.d.ts +1 -1
- package/lib/init/init.d.ts.map +1 -1
- package/lib/init/init.js.map +1 -1
- package/lib/init/templates.d.ts.map +1 -1
- package/lib/init/templates.js +0 -2
- package/lib/init/templates.js.map +1 -1
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.js +5 -2
- package/lib/package.spec.js.map +1 -1
- package/lib/props/props.d.ts +1 -1
- package/lib/props/props.d.ts.map +1 -1
- package/lib/props/props.js +6 -3
- package/lib/props/props.js.map +1 -1
- package/lib/serve/serve-manager.d.ts.map +1 -1
- package/lib/serve/serve-manager.js.map +1 -1
- package/lib/serve/serve.d.ts +1 -1
- package/lib/serve/serve.d.ts.map +1 -1
- package/lib/serve/serve.js.map +1 -1
- package/lib/update/update.d.ts +1 -1
- package/lib/update/update.d.ts.map +1 -1
- package/lib/update/update.js.map +1 -1
- package/lib/utils/banner-util.js.map +1 -1
- package/package.json +9 -12
- package/src/cell.ts +1 -1
- package/src/init/init-manager.ts +1 -1
- package/src/init/templates.ts +0 -2
- package/src/package.spec.ts +1 -0
- package/src/props/props.ts +1 -1
- package/templates/accounts/tsconfig.json +7 -4
- package/templates/admin-app/tsconfig.json +7 -4
- package/templates/backend-app/package.json +3 -3
- package/templates/backend-app/test/home-controller.spec.ts +12 -9
- package/templates/backend-app/tsconfig.json +8 -5
- package/templates/cell-component/README.md +5 -14
- package/templates/cell-component/package.json +6 -6
- package/templates/cell-component/src/package.spec.ts +1 -0
- package/templates/cell-component/tsconfig.json +27 -1
- package/templates/database-app/tsconfig.json +7 -4
- package/templates/docker-app/tsconfig.json +7 -4
- package/templates/file-service/tsconfig.json +7 -4
- package/templates/jwt-app/package.json +3 -3
- package/templates/jwt-app/test/home-controller.spec.ts +12 -9
- package/templates/jwt-app/tsconfig.json +8 -5
- package/templates/microservice/examples/backend-app/tsconfig.json +7 -4
- package/templates/microservice/package.json +8 -11
- package/templates/microservice/packages/api/tsconfig.json +7 -4
- package/templates/microservice/packages/serviceA/tsconfig.json +7 -4
- package/templates/microservice/packages/serviceB/tsconfig.json +7 -4
- package/templates/microservice/tsconfig.json +7 -4
- package/templates/mycli/package.json +1 -1
- package/templates/mycli/tsconfig.json +7 -4
- package/templates/nest-app/test/app.e2e-spec.ts +1 -1
- package/templates/nest-app/tsconfig.build.json +9 -1
- package/templates/nest-app/tsconfig.json +7 -3
- package/templates/sample-app/tsconfig.json +7 -4
- package/templates/schedule/tsconfig.json +7 -4
- package/templates/standalone-app/tsconfig.json +7 -4
- package/templates/vue-app/tsconfig.json +6 -4
- package/LICENSE +0 -21
- package/templates/cell-component/.eslintrc.js +0 -10
- package/templates/microservice/lerna.json +0 -19
- package/templates/monorepo/.editorconfig +0 -12
- package/templates/monorepo/.eslintrc.js +0 -18
- package/templates/monorepo/.yarnrc +0 -1
- package/templates/monorepo/CHANGELOG.md +0 -5
- package/templates/monorepo/README.md +0 -0
- package/templates/monorepo/apps/sample-app/cell.yml +0 -0
- package/templates/monorepo/apps/sample-app/package.json +0 -33
- package/templates/monorepo/apps/sample-app/src/browser/assets/logo.png +0 -0
- package/templates/monorepo/apps/sample-app/src/browser/css-shims.d.ts +0 -30
- package/templates/monorepo/apps/sample-app/src/browser/hello.view.tsx +0 -31
- package/templates/monorepo/apps/sample-app/src/browser/module.ts +0 -3
- package/templates/monorepo/apps/sample-app/src/browser/style/hello.module.scss +0 -4
- package/templates/monorepo/apps/sample-app/src/common/welcome-protocol.ts +0 -5
- package/templates/monorepo/apps/sample-app/src/node/module.ts +0 -3
- package/templates/monorepo/apps/sample-app/src/node/welcome-server.ts +0 -9
- package/templates/monorepo/apps/sample-app/tsconfig.json +0 -30
- package/templates/monorepo/configs/root-compilation.tsconfig.json +0 -14
- package/templates/monorepo/configs/typedoc-tsconfig.json +0 -6
- package/templates/monorepo/configs/typedoc.json +0 -23
- package/templates/monorepo/lerna.json +0 -17
- package/templates/monorepo/package.json +0 -46
- package/templates/monorepo/packages/core/.eslintrc.js +0 -10
- package/templates/monorepo/packages/core/README.md +0 -1
- package/templates/monorepo/packages/core/cell.yml +0 -0
- package/templates/monorepo/packages/core/package.json +0 -40
- package/templates/monorepo/packages/core/src/browser/index.ts +0 -0
- package/templates/monorepo/packages/core/src/browser/module.ts +0 -4
- package/templates/monorepo/packages/core/src/common/index.ts +0 -0
- package/templates/monorepo/packages/core/src/common/module.ts +0 -4
- package/templates/monorepo/packages/core/src/node/index.ts +0 -0
- package/templates/monorepo/packages/core/src/node/module.ts +0 -4
- package/templates/monorepo/packages/core/src/package.spec.ts +0 -4
- package/templates/monorepo/packages/core/tsconfig.json +0 -13
- package/templates/monorepo/scripts/check-publish.js +0 -40
- package/templates/monorepo/scripts/compile-references.js +0 -286
- package/templates/monorepo/tsconfig.json +0 -20
- package/templates/monorepo/tsfmt.json +0 -3
- package/templates/puppeteer/.github/workflows/deploy.yml +0 -25
- package/templates/puppeteer/.vscode/launch.json +0 -23
- package/templates/puppeteer/README.md +0 -92
- package/templates/puppeteer/cell.yml +0 -11
- package/templates/puppeteer/package.json +0 -31
- package/templates/puppeteer/src/home-controller.ts +0 -11
- package/templates/puppeteer/src/module.ts +0 -5
- package/templates/puppeteer/src/puppeteer-controller.ts +0 -26
- package/templates/puppeteer/tsconfig.json +0 -29
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
'use-strict';
|
|
3
|
-
|
|
4
|
-
const cp = require('child_process');
|
|
5
|
-
const path = require('path').posix;
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
|
|
8
|
-
const ROOT = path.join(__dirname, '..');
|
|
9
|
-
|
|
10
|
-
const DRY_RUN = popFlag(process.argv, '--dry-run');
|
|
11
|
-
|
|
12
|
-
const FORCE_REWRITE = popFlag(process.argv, '--force-rewrite') && !DRY_RUN;
|
|
13
|
-
|
|
14
|
-
/** @type {{ [packageName: string]: YarnWorkspace }} */
|
|
15
|
-
const YARN_WORKSPACES = JSON.parse(cp.execSync('yarn --silent workspaces info').toString());
|
|
16
|
-
|
|
17
|
-
// Add the package name inside each package object.
|
|
18
|
-
for (const [packageName, yarnWorkspace] of Object.entries(YARN_WORKSPACES)) {
|
|
19
|
-
yarnWorkspace.name = packageName;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** @type {YarnWorkspace} */
|
|
23
|
-
const MONOREPO = {
|
|
24
|
-
name: 'monorepo',
|
|
25
|
-
workspaceDependencies: Object.keys(YARN_WORKSPACES),
|
|
26
|
-
location: ROOT,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
let rewriteRequired = false;
|
|
31
|
-
let result = false;
|
|
32
|
-
|
|
33
|
-
// Configure all `compile.tsconfig.json` files of this monorepo
|
|
34
|
-
for (const packageName of Object.keys(YARN_WORKSPACES)) {
|
|
35
|
-
const workspacePackage = YARN_WORKSPACES[packageName];
|
|
36
|
-
const tsconfigCompilePath = path.join(ROOT, workspacePackage.location, 'compile.tsconfig.json');
|
|
37
|
-
const references = getTypescriptReferences(workspacePackage);
|
|
38
|
-
result = configureTypeScriptCompilation(workspacePackage, tsconfigCompilePath, references);
|
|
39
|
-
rewriteRequired = rewriteRequired || result;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Configure our root compilation configuration, living inside `configs/root-compilation.tsconfig.json`.
|
|
43
|
-
const configsFolder = path.join(ROOT, 'configs');
|
|
44
|
-
const tsconfigCompilePath = path.join(configsFolder, 'root-compilation.tsconfig.json');
|
|
45
|
-
const references = getTypescriptReferences(MONOREPO, configsFolder);
|
|
46
|
-
result = configureTypeScriptCompilation(MONOREPO, tsconfigCompilePath, references);
|
|
47
|
-
rewriteRequired = rewriteRequired || result;
|
|
48
|
-
|
|
49
|
-
// Configure the root `tsconfig.json` for code navigation using `tsserver`.
|
|
50
|
-
const tsconfigNavPath = path.join(ROOT, 'tsconfig.json');
|
|
51
|
-
result = configureTypeScriptNavigation(MONOREPO, tsconfigNavPath);
|
|
52
|
-
rewriteRequired = rewriteRequired || result;
|
|
53
|
-
|
|
54
|
-
// CI will be able to tell if references got changed by looking at the exit code.
|
|
55
|
-
if (rewriteRequired) {
|
|
56
|
-
if (DRY_RUN) {
|
|
57
|
-
// Running a dry run usually only happens when a developer or CI runs the tests, so we only print the help then.
|
|
58
|
-
console.error('TypeScript references seem to be out of sync, run "yarn prepare:references" to fix.');
|
|
59
|
-
process.exitCode = 1;
|
|
60
|
-
} else {
|
|
61
|
-
console.warn('TypeScript references were out of sync and got updated.');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
} catch (error) {
|
|
66
|
-
console.error(error);
|
|
67
|
-
process.exitCode = 1;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @param {YarnWorkspace} requestedPackage
|
|
72
|
-
* @param {string} [overrideLocation] affects how relative paths are computed.
|
|
73
|
-
* @returns {string[]} project references for `requestedPackage`.
|
|
74
|
-
*/
|
|
75
|
-
function getTypescriptReferences(requestedPackage, overrideLocation) {
|
|
76
|
-
const references = [];
|
|
77
|
-
for (const dependency of requestedPackage.workspaceDependencies || []) {
|
|
78
|
-
const depWorkspace = YARN_WORKSPACES[dependency];
|
|
79
|
-
const depConfig = path.join(depWorkspace.location, 'compile.tsconfig.json');
|
|
80
|
-
if (!fs.existsSync(depConfig)) {
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
const relativePath = path.relative(overrideLocation || requestedPackage.location, depWorkspace.location);
|
|
84
|
-
references.push(relativePath);
|
|
85
|
-
}
|
|
86
|
-
return references;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Wires a given compilation tsconfig file according to the provided references.
|
|
91
|
-
* This allows TypeScript to operate in build mode.
|
|
92
|
-
*
|
|
93
|
-
* @param {YarnWorkspace} targetPackage for debug purpose.
|
|
94
|
-
* @param {string} tsconfigPath path to the tsconfig file to edit.
|
|
95
|
-
* @param {string[]} references list of paths to the related project roots.
|
|
96
|
-
* @returns {boolean} rewrite was needed.
|
|
97
|
-
*/
|
|
98
|
-
function configureTypeScriptCompilation(targetPackage, tsconfigPath, references) {
|
|
99
|
-
if (!fs.existsSync(tsconfigPath)) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
const tsconfigJson = readJsonFile(tsconfigPath);
|
|
103
|
-
|
|
104
|
-
let needRewrite = FORCE_REWRITE;
|
|
105
|
-
|
|
106
|
-
if (!tsconfigJson.compilerOptions) {
|
|
107
|
-
// Somehow no `compilerOptions` literal is defined.
|
|
108
|
-
tsconfigJson.compilerOptions = {
|
|
109
|
-
composite: true,
|
|
110
|
-
rootDir: 'src',
|
|
111
|
-
outDir: 'lib',
|
|
112
|
-
};
|
|
113
|
-
needRewrite = true;
|
|
114
|
-
|
|
115
|
-
} else if (!tsconfigJson.compilerOptions.composite) {
|
|
116
|
-
// `compilerOptions` is missing the `composite` literal.
|
|
117
|
-
tsconfigJson.compilerOptions = {
|
|
118
|
-
composite: true,
|
|
119
|
-
...tsconfigJson.compilerOptions,
|
|
120
|
-
};
|
|
121
|
-
needRewrite = true;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** @type {string[]} */
|
|
125
|
-
const tsconfigReferences = references
|
|
126
|
-
.map(reference => path.join(reference, 'compile.tsconfig.json'));
|
|
127
|
-
|
|
128
|
-
/** @type {string[]} */
|
|
129
|
-
const currentReferences = (tsconfigJson['references'] || [])
|
|
130
|
-
// We will work on a set of paths, easier to handle than objects.
|
|
131
|
-
.map(reference => reference.path)
|
|
132
|
-
// Remove any invalid reference (maybe outdated).
|
|
133
|
-
.filter((referenceRelativePath, index, self) => {
|
|
134
|
-
if (!tsconfigReferences.includes(referenceRelativePath)) {
|
|
135
|
-
// Found a reference that wasn't automatically computed, will remove.
|
|
136
|
-
console.warn(`error: ${targetPackage.name} untracked reference: ${referenceRelativePath}`);
|
|
137
|
-
needRewrite = true;
|
|
138
|
-
return false; // remove
|
|
139
|
-
}
|
|
140
|
-
if (self.indexOf(referenceRelativePath) !== index) {
|
|
141
|
-
// Remove duplicates.
|
|
142
|
-
console.error(`error: ${targetPackage.name} duplicate reference: ${referenceRelativePath}`);
|
|
143
|
-
needRewrite = true;
|
|
144
|
-
return false; // remove
|
|
145
|
-
}
|
|
146
|
-
const referencePath = path.join(path.dirname(tsconfigPath), referenceRelativePath);
|
|
147
|
-
try {
|
|
148
|
-
const referenceStat = fs.statSync(referencePath);
|
|
149
|
-
if (referenceStat.isDirectory() && fs.statSync(path.join(referencePath, 'tsconfig.json')).isFile()) {
|
|
150
|
-
return true; // keep
|
|
151
|
-
} else if (referenceStat.isFile()) { // still could be something else than a tsconfig, but good enough.
|
|
152
|
-
return true; // keep
|
|
153
|
-
}
|
|
154
|
-
} catch {
|
|
155
|
-
// passthrough
|
|
156
|
-
}
|
|
157
|
-
console.error(`error: ${targetPackage.name} invalid reference: ${referenceRelativePath}`);
|
|
158
|
-
needRewrite = true;
|
|
159
|
-
return false; // remove
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
for (const tsconfigReference of tsconfigReferences) {
|
|
163
|
-
if (!currentReferences.includes(tsconfigReference)) {
|
|
164
|
-
console.error(`error: ${targetPackage.name} missing reference: ${tsconfigReference}`);
|
|
165
|
-
currentReferences.push(tsconfigReference);
|
|
166
|
-
needRewrite = true;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (!DRY_RUN && needRewrite) {
|
|
170
|
-
tsconfigJson.references = currentReferences.map(path => ({ path }));
|
|
171
|
-
const content = JSON.stringify(tsconfigJson, undefined, 2);
|
|
172
|
-
fs.writeFileSync(tsconfigPath, content + '\n');
|
|
173
|
-
console.warn(`info: ${tsconfigPath} updated.`);
|
|
174
|
-
}
|
|
175
|
-
return needRewrite;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Wire the root `tsconfig.json` to map scoped import to real location in the monorepo.
|
|
180
|
-
* This setup is a shim for the TypeScript language server to provide cross-package navigation.
|
|
181
|
-
* Compilation is done via `compile.tsconfig.json` files.
|
|
182
|
-
*
|
|
183
|
-
* @param {YarnWorkspace} targetPackage for debug purpose.
|
|
184
|
-
* @param {string} tsconfigPath
|
|
185
|
-
* @returns {boolean} rewrite was needed.
|
|
186
|
-
*/
|
|
187
|
-
function configureTypeScriptNavigation(targetPackage, tsconfigPath) {
|
|
188
|
-
const tsconfigJson = readJsonFile(tsconfigPath);
|
|
189
|
-
|
|
190
|
-
let needRewrite = FORCE_REWRITE;
|
|
191
|
-
|
|
192
|
-
if (typeof tsconfigJson.compilerOptions === 'undefined') {
|
|
193
|
-
// Somehow no `compilerOptions` literal is defined.
|
|
194
|
-
tsconfigJson.compilerOptions = {
|
|
195
|
-
baseUrl: '.',
|
|
196
|
-
paths: {},
|
|
197
|
-
};
|
|
198
|
-
needRewrite = true;
|
|
199
|
-
|
|
200
|
-
} else if (typeof tsconfigJson.compilerOptions.paths === 'undefined') {
|
|
201
|
-
// `compilerOptions` is missing the `paths` literal.
|
|
202
|
-
tsconfigJson.compilerOptions = {
|
|
203
|
-
...tsconfigJson.compilerOptions,
|
|
204
|
-
paths: {},
|
|
205
|
-
};
|
|
206
|
-
needRewrite = true;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/** @type {{ [prefix: string]: string[] }} */
|
|
210
|
-
const currentPaths = tsconfigJson.compilerOptions.paths;
|
|
211
|
-
|
|
212
|
-
for (const packageName of MONOREPO.workspaceDependencies) {
|
|
213
|
-
const depWorkspace = YARN_WORKSPACES[packageName];
|
|
214
|
-
|
|
215
|
-
/** @type {string} */
|
|
216
|
-
let originalImportPath;
|
|
217
|
-
/** @type {string} */
|
|
218
|
-
let mappedFsPath;
|
|
219
|
-
|
|
220
|
-
const depSrcPath = path.join(depWorkspace.location, 'src');
|
|
221
|
-
const depConfigPath = path.join(depWorkspace.location, 'compile.tsconfig.json');
|
|
222
|
-
|
|
223
|
-
if (fs.existsSync(depConfigPath) && fs.existsSync(depSrcPath)) {
|
|
224
|
-
// If it is a TypeScript dependency, map `lib` imports to our local sources in `src`.
|
|
225
|
-
const depConfigJson = readJsonFile(depConfigPath);
|
|
226
|
-
originalImportPath = `${packageName}/${depConfigJson.compilerOptions.outDir}/*`;
|
|
227
|
-
mappedFsPath = path.relative(MONOREPO.location, path.join(depSrcPath, '*'));
|
|
228
|
-
|
|
229
|
-
} else {
|
|
230
|
-
// I don't really know what to do here, simply point to our local package root.
|
|
231
|
-
originalImportPath = `${packageName}/*`;
|
|
232
|
-
mappedFsPath = path.relative(MONOREPO.location, path.join(depWorkspace.location, '*'));
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/** @type {string[] | undefined} */
|
|
236
|
-
const currentFsPaths = currentPaths[originalImportPath];
|
|
237
|
-
|
|
238
|
-
if (typeof currentFsPaths === 'undefined' || currentFsPaths.length !== 1 || currentFsPaths[0] !== mappedFsPath) {
|
|
239
|
-
console.error(`error: ${targetPackage.name} invalid mapped path: {"${originalImportPath}": "${currentFsPaths}"}`);
|
|
240
|
-
currentPaths[originalImportPath] = [mappedFsPath];
|
|
241
|
-
needRewrite = true;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
if (!DRY_RUN && needRewrite) {
|
|
245
|
-
const content = JSON.stringify(tsconfigJson, undefined, 2);
|
|
246
|
-
fs.writeFileSync(tsconfigPath, content + '\n');
|
|
247
|
-
console.warn(`info: ${tsconfigPath} updated.`);
|
|
248
|
-
}
|
|
249
|
-
return needRewrite;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
*
|
|
254
|
-
* @param {string[]} argv
|
|
255
|
-
* @param {string} flag
|
|
256
|
-
* @returns {boolean}
|
|
257
|
-
*/
|
|
258
|
-
function popFlag(argv, flag) {
|
|
259
|
-
const flagIndex = argv.indexOf(flag)
|
|
260
|
-
if (flagIndex !== -1) {
|
|
261
|
-
argv.splice(flagIndex, 1);
|
|
262
|
-
return true;
|
|
263
|
-
} else {
|
|
264
|
-
return false;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* @param {string} filePath
|
|
270
|
-
* @returns {any}
|
|
271
|
-
*/
|
|
272
|
-
function readJsonFile(filePath) {
|
|
273
|
-
try {
|
|
274
|
-
return JSON.parse(fs.readFileSync(filePath).toString());
|
|
275
|
-
} catch (error) {
|
|
276
|
-
console.error('ParseError in file:', filePath);
|
|
277
|
-
throw error;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* @typedef YarnWorkspace
|
|
283
|
-
* @property {string} name
|
|
284
|
-
* @property {string} location
|
|
285
|
-
* @property {string[]} workspaceDependencies
|
|
286
|
-
*/
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@celljs/style-guide/typescript",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"allowJs": true,
|
|
5
|
-
"noEmit": true,
|
|
6
|
-
"baseUrl": ".",
|
|
7
|
-
"paths": {
|
|
8
|
-
"@app/core/lib/*": [
|
|
9
|
-
"packages/core/src/*"
|
|
10
|
-
],
|
|
11
|
-
"@app/app-sample-app/*": [
|
|
12
|
-
"apps/sample-app/*"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"include": [
|
|
17
|
-
"packages/*/src",
|
|
18
|
-
"apps/*/test"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: Cell Deploy
|
|
2
|
-
|
|
3
|
-
on: push
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
cell-deploy:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
steps:
|
|
9
|
-
- uses: actions/checkout@v2
|
|
10
|
-
- name: Setup node
|
|
11
|
-
uses: actions/setup-node@v1
|
|
12
|
-
with:
|
|
13
|
-
node-version: '12'
|
|
14
|
-
- uses: bahmutov/npm-install@v1
|
|
15
|
-
- run: npm run lint --if-present
|
|
16
|
-
- run: npm test
|
|
17
|
-
- if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
|
|
18
|
-
env: ${{ secrets }}
|
|
19
|
-
run: npx cell deploy -m prod
|
|
20
|
-
- if: ${{ github.ref == 'refs/heads/pre' }}
|
|
21
|
-
env: ${{ secrets }}
|
|
22
|
-
run: npx cell deploy -m pre
|
|
23
|
-
- if: ${{ github.ref != 'refs/heads/master' && github.ref == 'refs/heads/main' && github.ref != 'refs/heads/pre' }}
|
|
24
|
-
env: ${{ secrets }}
|
|
25
|
-
run: npx cell deploy -m test
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"name": "Cell Debug",
|
|
6
|
-
"request": "launch",
|
|
7
|
-
"runtimeArgs": [
|
|
8
|
-
"cell",
|
|
9
|
-
"serve"
|
|
10
|
-
],
|
|
11
|
-
"runtimeExecutable": "npx",
|
|
12
|
-
"skipFiles": [
|
|
13
|
-
"<node_internals>/**"
|
|
14
|
-
],
|
|
15
|
-
"env": {
|
|
16
|
-
"NODE_ENV": "development"
|
|
17
|
-
},
|
|
18
|
-
"internalConsoleOptions": "openOnSessionStart",
|
|
19
|
-
"outputCapture": "std",
|
|
20
|
-
"type": "pwa-node"
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# 开发说明
|
|
2
|
-
|
|
3
|
-
## 安装依赖
|
|
4
|
-
|
|
5
|
-
以下使用 yarn 工具来说明,你也可以使用 npm。
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# 通过 cell init 初始化应用的时候已经自动安装了依赖,所以你只需要安装你额外需要的依赖即可
|
|
9
|
-
|
|
10
|
-
$ yarn add xxxx
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## 本地运行
|
|
14
|
-
|
|
15
|
-
```shell
|
|
16
|
-
# 启动本地服务,端口默认 3000 或者 9000
|
|
17
|
-
# 在终端中会输出本地服务的 URL 链接
|
|
18
|
-
|
|
19
|
-
$ yarn start # 或者执行 cell serve 命令
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## 构建部署
|
|
23
|
-
|
|
24
|
-
模板默认提供了四套隔离环境:本地(local)、测试(test)、预发(pre)、线上(prod)。每个环境对应着一个 cell 配置文件(可选),类似 cell-test.yml。而 cell.yml 文件一般用于放所有环境的公共配置。第一次部署的时候可能会提示你填写相关云厂商 ak 信息。如果是 Vercel 云平台的模板,会提示你需要登录到 Vercel 平台。你也可以在项目通过 .env 提供云厂商的 ak 信息。
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
|
|
28
|
-
$ cell deploy -m scf # 部署到腾讯云函数测试环境
|
|
29
|
-
$ cell deploy -m scf -m test # 部署到腾讯云测试环境
|
|
30
|
-
$ cell deploy -m scf -m pre # 部署到腾讯云预发环境
|
|
31
|
-
$ cell deploy -m scf -m prod # 部署到腾讯云线上环境
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## 关于 Cell Framework
|
|
36
|
-
|
|
37
|
-
Cell 是基于 TypeScript 的 Serverless First、组件化、平台无关的渐进式应用框架。
|
|
38
|
-
|
|
39
|
-
## 特征
|
|
40
|
-
|
|
41
|
-
- 约定大于配置,零配置,开箱即用
|
|
42
|
-
- TypeScript 版 Spring Boot
|
|
43
|
-
- Serverless First
|
|
44
|
-
- 平台不锁定
|
|
45
|
-
- 支持前后端一体化,前端框架不锁定
|
|
46
|
-
- 支持微服务
|
|
47
|
-
- 组件化,渐进式
|
|
48
|
-
- 命令行工具插件化
|
|
49
|
-
- 依赖注入
|
|
50
|
-
- 面向切面编程(AOP)
|
|
51
|
-
- 集成了流行的 ORM 框架,使用装饰器声明式事务管理
|
|
52
|
-
- 支持 OIDC 认证
|
|
53
|
-
- 支持 OAuth2 授权
|
|
54
|
-
- 使用 rxjs 管理状态
|
|
55
|
-
- 提供 REST 和 RPC 两种接口风格
|
|
56
|
-
|
|
57
|
-
Cell 名字由来:在我的家乡,谐音“吗啦咕”是小石头的意思,小石头堆砌起来可以建成高楼大厦、道路桥梁,而 Cell 组件编排可以实现千变万化的应用。
|
|
58
|
-
|
|
59
|
-
## 快速开始
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
# 安装命令行工具
|
|
63
|
-
npm install -g @celljs/cli
|
|
64
|
-
|
|
65
|
-
# 初始化
|
|
66
|
-
cell init -o project-name
|
|
67
|
-
cd project-name # 进入项目根目录
|
|
68
|
-
|
|
69
|
-
# 运行
|
|
70
|
-
cell serve
|
|
71
|
-
|
|
72
|
-
# 部署
|
|
73
|
-
cell deploy
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
[](https://asciinema.org/a/474104?speed=2.5&autoplay=1)
|
|
77
|
-
|
|
78
|
-
### 文档
|
|
79
|
-
|
|
80
|
-
- [介绍](https://cell.cellbang.com/guide/%E4%BB%8B%E7%BB%8D)
|
|
81
|
-
- [创建第一个应用](https://cell.cellbang.com/guide/%E5%88%9B%E5%BB%BA%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8)
|
|
82
|
-
- [命令行工具](https://cell.cellbang.com/guide/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%B7%A5%E5%85%B7)
|
|
83
|
-
- [控制器](https://cell.cellbang.com/guide/%E6%8E%A7%E5%88%B6%E5%99%A8)
|
|
84
|
-
- [数据库操作](https://cell.cellbang.com/guide/%E6%95%B0%E6%8D%AE%E5%BA%93typeorm)
|
|
85
|
-
- [微服务](https://cell.cellbang.com/dev/%E5%BE%AE%E6%9C%8D%E5%8A%A1)
|
|
86
|
-
- [认证与授权](https://cell.cellbang.com/guide/%E8%AE%A4%E8%AF%81%E4%B8%8E%E6%8E%88%E6%9D%83)
|
|
87
|
-
- [云平台适配](https://cell.cellbang.com/cloud/%E4%BA%91%E5%B9%B3%E5%8F%B0%E9%80%82%E9%85%8D)
|
|
88
|
-
- [依赖注入](https://cell.cellbang.com/guide/%E4%BE%9D%E8%B5%96%E6%B3%A8%E5%85%A5)
|
|
89
|
-
- [组件设计](https://cell.cellbang.com/guide/%E7%BB%84%E4%BB%B6%E8%AE%BE%E8%AE%A1)
|
|
90
|
-
- [前端架构](https://cell.cellbang.com/guide/%E5%89%8D%E7%AB%AF%E6%9E%B6%E6%9E%84)
|
|
91
|
-
- [React 开发](https://cell.cellbang.com/dev/react)
|
|
92
|
-
- [前后端一体化开发](https://cell.cellbang.com/dev/%E5%89%8D%E5%90%8E%E7%AB%AF%E4%B8%80%E4%BD%93%E5%8C%96%E5%BC%80%E5%8F%91)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
mode: fc
|
|
2
|
-
|
|
3
|
-
cell:
|
|
4
|
-
cloud:
|
|
5
|
-
region: cn-hangzhou # 指定存放 headless 相关二进制的 oss 的地域,建议与应用部署的地域一致
|
|
6
|
-
credentials:
|
|
7
|
-
accessKeyId: xxxxxxxxxxxxxxxxxxxxxxxx # 指定能够访问存放 headless 相关二进制 accessKeyId,至少具有读该 Object 的权限
|
|
8
|
-
accessKeySecret: xxxxxxxxxxxxxxxxxxxxxx
|
|
9
|
-
puppeteer:
|
|
10
|
-
bucket: headless-lib # 指定存放 headless 相关二进制的 oss 的 Bucket 名称 headless-lib
|
|
11
|
-
object: headless-lib.tar.gz # 指定存放 headless 相关二进制的 oss 的 objeck 名称,默认 headless-lib.tar.gz
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "puppeteer",
|
|
3
|
-
"keywords": [
|
|
4
|
-
"cell-component"
|
|
5
|
-
],
|
|
6
|
-
"version": "0.0.0",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"files": [
|
|
9
|
-
"lib",
|
|
10
|
-
"src"
|
|
11
|
-
],
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@celljs/core": "{{ version }}",
|
|
14
|
-
"@celljs/mvc": "{{ version }}",
|
|
15
|
-
"@celljs/web": "{{ version }}",
|
|
16
|
-
"@celljs/puppeteer": "{{ version }}",
|
|
17
|
-
"@celljs/oss": "{{ version }}"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"@celljs/cli": "{{ version }}"
|
|
21
|
-
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"clean": "rimraf lib dist .cell",
|
|
24
|
-
"build": "cell build",
|
|
25
|
-
"start": "cell serve",
|
|
26
|
-
"deploy": "cell deploy -m fc -m test",
|
|
27
|
-
"deploy:test": "cell deploy -m fc -m test",
|
|
28
|
-
"deploy:pre": "cell deploy -m fc -m pre",
|
|
29
|
-
"deploy:prod": "cell deploy -m fc -m prod"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Autowired } from '@celljs/core';
|
|
2
|
-
import { Context } from '@celljs/web/lib/node';
|
|
3
|
-
import { Controller, Get, Query, File } from '@celljs/mvc/lib/node';
|
|
4
|
-
import { BrowserProvider } from '@celljs/puppeteer';
|
|
5
|
-
|
|
6
|
-
@Controller()
|
|
7
|
-
export class PuppeteerController {
|
|
8
|
-
|
|
9
|
-
@Autowired(BrowserProvider)
|
|
10
|
-
protected readonly browserProvider: BrowserProvider;
|
|
11
|
-
|
|
12
|
-
@Get('screenshot')
|
|
13
|
-
@File()
|
|
14
|
-
async screenshot(@Query('url') url?: string) {
|
|
15
|
-
const response = Context.getResponse();
|
|
16
|
-
response.attachment('download.png');
|
|
17
|
-
const browser = await this.browserProvider.provide();
|
|
18
|
-
const page = await browser.newPage();
|
|
19
|
-
try {
|
|
20
|
-
await page.goto(url || 'https://baidu.com', { waitUntil: 'networkidle0' });
|
|
21
|
-
return await page.screenshot();
|
|
22
|
-
} finally {
|
|
23
|
-
await page.close();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"skipLibCheck": true,
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"declarationMap": true,
|
|
6
|
-
"noImplicitAny": true,
|
|
7
|
-
"noEmitOnError": false,
|
|
8
|
-
"noImplicitThis": true,
|
|
9
|
-
"noUnusedLocals": true,
|
|
10
|
-
"strictNullChecks": true,
|
|
11
|
-
"experimentalDecorators": true,
|
|
12
|
-
"emitDecoratorMetadata": true,
|
|
13
|
-
"downlevelIteration": true,
|
|
14
|
-
"module": "commonjs",
|
|
15
|
-
"moduleResolution": "node",
|
|
16
|
-
"jsx": "react",
|
|
17
|
-
"target": "ES2017",
|
|
18
|
-
"lib": [
|
|
19
|
-
"ES2017",
|
|
20
|
-
"dom"
|
|
21
|
-
],
|
|
22
|
-
"sourceMap": true,
|
|
23
|
-
"rootDir": "src",
|
|
24
|
-
"outDir": "lib"
|
|
25
|
-
},
|
|
26
|
-
"include": [
|
|
27
|
-
"src"
|
|
28
|
-
]
|
|
29
|
-
}
|