@celljs/cli 3.7.8 → 3.9.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.
Files changed (148) hide show
  1. package/lib/build/build-manager.d.ts.map +1 -1
  2. package/lib/build/build-manager.js.map +1 -1
  3. package/lib/build/build.d.ts +1 -1
  4. package/lib/build/build.d.ts.map +1 -1
  5. package/lib/build/build.js.map +1 -1
  6. package/lib/cell.js +8 -5
  7. package/lib/cell.js.map +1 -1
  8. package/lib/config/config.d.ts +1 -1
  9. package/lib/config/config.d.ts.map +1 -1
  10. package/lib/config/config.js.map +1 -1
  11. package/lib/deploy/deploy.d.ts +1 -1
  12. package/lib/deploy/deploy.d.ts.map +1 -1
  13. package/lib/deploy/deploy.js +4 -1
  14. package/lib/deploy/deploy.js.map +1 -1
  15. package/lib/index.d.ts +1 -0
  16. package/lib/index.js +2 -0
  17. package/lib/info/info.d.ts +1 -1
  18. package/lib/info/info.d.ts.map +1 -1
  19. package/lib/info/info.js.map +1 -1
  20. package/lib/init/init-manager.d.ts.map +1 -1
  21. package/lib/init/init-manager.js +5 -2
  22. package/lib/init/init-manager.js.map +1 -1
  23. package/lib/init/init.d.ts +1 -1
  24. package/lib/init/init.d.ts.map +1 -1
  25. package/lib/init/init.js.map +1 -1
  26. package/lib/init/templates.d.ts.map +1 -1
  27. package/lib/init/templates.js +0 -2
  28. package/lib/init/templates.js.map +1 -1
  29. package/lib/package.spec.d.ts +1 -0
  30. package/lib/package.spec.js +5 -2
  31. package/lib/package.spec.js.map +1 -1
  32. package/lib/props/props.d.ts +1 -1
  33. package/lib/props/props.d.ts.map +1 -1
  34. package/lib/props/props.js +6 -3
  35. package/lib/props/props.js.map +1 -1
  36. package/lib/serve/serve-manager.d.ts.map +1 -1
  37. package/lib/serve/serve-manager.js.map +1 -1
  38. package/lib/serve/serve.d.ts +1 -1
  39. package/lib/serve/serve.d.ts.map +1 -1
  40. package/lib/serve/serve.js.map +1 -1
  41. package/lib/update/update.d.ts +1 -1
  42. package/lib/update/update.d.ts.map +1 -1
  43. package/lib/update/update.js.map +1 -1
  44. package/lib/utils/banner-util.js.map +1 -1
  45. package/package.json +9 -12
  46. package/src/cell.ts +1 -1
  47. package/src/init/init-manager.ts +1 -1
  48. package/src/init/templates.ts +0 -2
  49. package/src/package.spec.ts +1 -0
  50. package/src/props/props.ts +1 -1
  51. package/templates/accounts/README.md +0 -16
  52. package/templates/accounts/cell.yml +1 -1
  53. package/templates/accounts/tsconfig.json +7 -4
  54. package/templates/admin-app/README.md +0 -16
  55. package/templates/admin-app/tsconfig.json +7 -4
  56. package/templates/backend-app/README.md +0 -16
  57. package/templates/backend-app/package.json +3 -3
  58. package/templates/backend-app/test/home-controller.spec.ts +12 -9
  59. package/templates/backend-app/tsconfig.json +8 -5
  60. package/templates/cell-component/README.md +5 -14
  61. package/templates/cell-component/package.json +6 -6
  62. package/templates/cell-component/src/package.spec.ts +1 -0
  63. package/templates/cell-component/tsconfig.json +27 -1
  64. package/templates/database-app/README.md +0 -16
  65. package/templates/database-app/tsconfig.json +7 -4
  66. package/templates/docker-app/README.md +0 -16
  67. package/templates/docker-app/src/browser/hello.view.tsx +1 -1
  68. package/templates/docker-app/tsconfig.json +7 -4
  69. package/templates/file-service/README.md +0 -16
  70. package/templates/file-service/tsconfig.json +7 -4
  71. package/templates/jwt-app/README.md +0 -16
  72. package/templates/jwt-app/package.json +3 -3
  73. package/templates/jwt-app/test/home-controller.spec.ts +12 -9
  74. package/templates/jwt-app/tsconfig.json +8 -5
  75. package/templates/microservice/README.md +0 -16
  76. package/templates/microservice/examples/backend-app/README.md +0 -16
  77. package/templates/microservice/examples/backend-app/tsconfig.json +7 -4
  78. package/templates/microservice/package.json +8 -11
  79. package/templates/microservice/packages/api/README.md +0 -16
  80. package/templates/microservice/packages/api/tsconfig.json +7 -4
  81. package/templates/microservice/packages/serviceA/README.md +0 -16
  82. package/templates/microservice/packages/serviceA/tsconfig.json +7 -4
  83. package/templates/microservice/packages/serviceB/README.md +0 -16
  84. package/templates/microservice/packages/serviceB/tsconfig.json +7 -4
  85. package/templates/microservice/tsconfig.json +7 -4
  86. package/templates/mycli/package.json +1 -1
  87. package/templates/mycli/tsconfig.json +7 -4
  88. package/templates/nest-app/test/app.e2e-spec.ts +1 -1
  89. package/templates/nest-app/tsconfig.build.json +9 -1
  90. package/templates/nest-app/tsconfig.json +7 -3
  91. package/templates/sample-app/README.md +0 -16
  92. package/templates/sample-app/src/browser/hello.view.tsx +1 -1
  93. package/templates/sample-app/tsconfig.json +7 -4
  94. package/templates/schedule/README.md +0 -16
  95. package/templates/schedule/tsconfig.json +7 -4
  96. package/templates/standalone-app/tsconfig.json +7 -4
  97. package/templates/vue-app/README.md +0 -16
  98. package/templates/vue-app/src/browser/components/HelloWorld.vue +2 -2
  99. package/templates/vue-app/tsconfig.json +6 -4
  100. package/LICENSE +0 -21
  101. package/templates/cell-component/.eslintrc.js +0 -10
  102. package/templates/microservice/lerna.json +0 -19
  103. package/templates/monorepo/.editorconfig +0 -12
  104. package/templates/monorepo/.eslintrc.js +0 -18
  105. package/templates/monorepo/.yarnrc +0 -1
  106. package/templates/monorepo/CHANGELOG.md +0 -5
  107. package/templates/monorepo/README.md +0 -0
  108. package/templates/monorepo/apps/sample-app/cell.yml +0 -0
  109. package/templates/monorepo/apps/sample-app/package.json +0 -33
  110. package/templates/monorepo/apps/sample-app/src/browser/assets/logo.png +0 -0
  111. package/templates/monorepo/apps/sample-app/src/browser/css-shims.d.ts +0 -30
  112. package/templates/monorepo/apps/sample-app/src/browser/hello.view.tsx +0 -31
  113. package/templates/monorepo/apps/sample-app/src/browser/module.ts +0 -3
  114. package/templates/monorepo/apps/sample-app/src/browser/style/hello.module.scss +0 -4
  115. package/templates/monorepo/apps/sample-app/src/common/welcome-protocol.ts +0 -5
  116. package/templates/monorepo/apps/sample-app/src/node/module.ts +0 -3
  117. package/templates/monorepo/apps/sample-app/src/node/welcome-server.ts +0 -9
  118. package/templates/monorepo/apps/sample-app/tsconfig.json +0 -30
  119. package/templates/monorepo/configs/root-compilation.tsconfig.json +0 -14
  120. package/templates/monorepo/configs/typedoc-tsconfig.json +0 -6
  121. package/templates/monorepo/configs/typedoc.json +0 -23
  122. package/templates/monorepo/lerna.json +0 -17
  123. package/templates/monorepo/package.json +0 -46
  124. package/templates/monorepo/packages/core/.eslintrc.js +0 -10
  125. package/templates/monorepo/packages/core/README.md +0 -1
  126. package/templates/monorepo/packages/core/cell.yml +0 -0
  127. package/templates/monorepo/packages/core/package.json +0 -40
  128. package/templates/monorepo/packages/core/src/browser/index.ts +0 -0
  129. package/templates/monorepo/packages/core/src/browser/module.ts +0 -4
  130. package/templates/monorepo/packages/core/src/common/index.ts +0 -0
  131. package/templates/monorepo/packages/core/src/common/module.ts +0 -4
  132. package/templates/monorepo/packages/core/src/node/index.ts +0 -0
  133. package/templates/monorepo/packages/core/src/node/module.ts +0 -4
  134. package/templates/monorepo/packages/core/src/package.spec.ts +0 -4
  135. package/templates/monorepo/packages/core/tsconfig.json +0 -13
  136. package/templates/monorepo/scripts/check-publish.js +0 -40
  137. package/templates/monorepo/scripts/compile-references.js +0 -286
  138. package/templates/monorepo/tsconfig.json +0 -20
  139. package/templates/monorepo/tsfmt.json +0 -3
  140. package/templates/puppeteer/.github/workflows/deploy.yml +0 -25
  141. package/templates/puppeteer/.vscode/launch.json +0 -23
  142. package/templates/puppeteer/README.md +0 -92
  143. package/templates/puppeteer/cell.yml +0 -11
  144. package/templates/puppeteer/package.json +0 -31
  145. package/templates/puppeteer/src/home-controller.ts +0 -11
  146. package/templates/puppeteer/src/module.ts +0 -5
  147. package/templates/puppeteer/src/puppeteer-controller.ts +0 -26
  148. package/templates/puppeteer/tsconfig.json +0 -29
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
- import { RpcUtil } from '@celljs/rpc/lib/common';
3
- import { WelcomeServer } from '../common/welcome-protocol';
4
- import { View } from '@celljs/react';
5
- import styles from './style/hello.module.scss';
6
-
7
- const Hello = () => {
8
- const [ response, setResponse ] = React.useState('Loading');
9
- React.useEffect(() => {
10
- const welcomeServer = RpcUtil.get<WelcomeServer>(WelcomeServer);
11
- const init = async () => {
12
- setResponse(await welcomeServer.say());
13
- }
14
- init();
15
- }, []);
16
-
17
- return <div className={ styles.hello }>
18
- <img alt="cell logo" src="./assets/logo.png"></img>
19
- <div className="hello">
20
- <h1>{response}</h1>
21
- <p>
22
- For a guide and recipes on how to configure / customize this project,<br />
23
- check out the <a href="https://cell.cellbang.com/" target="_blank" rel="noopener">cell documentation</a>.
24
- </p>
25
- </div>
26
- </div>
27
-
28
- }
29
-
30
- @View({ index: true, component: Hello })
31
- export default class {}
@@ -1,3 +0,0 @@
1
- import './hello.view';
2
- import { autoBind } from '@celljs/core';
3
- export default autoBind();
@@ -1,4 +0,0 @@
1
- .hello {
2
- text-align: center;
3
- margin-top: 40px
4
- }
@@ -1,5 +0,0 @@
1
- export const WelcomeServer = Symbol('WelcomeServer');
2
-
3
- export interface WelcomeServer {
4
- say(): Promise<string>;
5
- }
@@ -1,3 +0,0 @@
1
- import './welcome-server';
2
- import { autoBind } from '@celljs/core';
3
- export default autoBind();
@@ -1,9 +0,0 @@
1
- import { WelcomeServer } from '../common/welcome-protocol';
2
- import { Rpc } from '@celljs/rpc';
3
-
4
- @Rpc(WelcomeServer)
5
- export class WelcomeServerImpl implements WelcomeServer {
6
- say(): Promise<string> {
7
- return Promise.resolve('Welcome to Cell');
8
- }
9
- }
@@ -1,30 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "skipLibCheck": true,
4
- "esModuleInterop": true,
5
- "declaration": true,
6
- "declarationMap": true,
7
- "noImplicitAny": true,
8
- "noEmitOnError": false,
9
- "noImplicitThis": true,
10
- "noUnusedLocals": true,
11
- "strictNullChecks": true,
12
- "experimentalDecorators": true,
13
- "emitDecoratorMetadata": true,
14
- "downlevelIteration": true,
15
- "module": "commonjs",
16
- "moduleResolution": "node",
17
- "jsx": "react",
18
- "target": "ES2017",
19
- "lib": [
20
- "ES2017",
21
- "dom"
22
- ],
23
- "sourceMap": true,
24
- "rootDir": "src",
25
- "outDir": "lib"
26
- },
27
- "include": [
28
- "src"
29
- ]
30
- }
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "@celljs/style-guide/typescript",
3
- "include": [],
4
- "compilerOptions": {
5
- "composite": true,
6
- "rootDir": "src",
7
- "outDir": "lib"
8
- },
9
- "references": [
10
- {
11
- "path": "../packages/core/compile.tsconfig.json"
12
- }
13
- ]
14
- }
@@ -1,6 +0,0 @@
1
- {
2
- "extends": "../tsconfig",
3
- "compilerOptions": {
4
- "skipLibCheck": true
5
- }
6
- }
@@ -1,23 +0,0 @@
1
- {
2
- "emit": "none",
3
- "compilerOptions": {
4
- "ignoreCompilerErrors": true,
5
- "skipLibCheck": true,
6
- "noEmitOnError": true,
7
- "allowJs": true
8
- },
9
- "exclude": [
10
- "../+(apps|typings|scripts)/**",
11
- "../packages/*/lib/**",
12
- "**/node_modules/**",
13
- "**/*.tsx",
14
- "**/*spec.ts"
15
- ],
16
- "excludeExternals": true,
17
- "external-modulemap": ".*\/(packages)\/([\\w\\-_]+)\/",
18
- "hideGenerator": true,
19
- "name": "App TypeDoc",
20
- "out": "../gh-pages/docs/next",
21
- "readme": "../README.md",
22
- "entryPointStrategy": "expand"
23
- }
@@ -1,17 +0,0 @@
1
- {
2
- "lerna": "2.2.0",
3
- "npmClient": "yarn",
4
- "useWorkspaces": true,
5
- "version": "0.0.0",
6
- "command": {
7
- "run": {
8
- "stream": true
9
- },
10
- "publish": {
11
- "graphType": "all",
12
- "forcePublish": true,
13
- "skipGit": true,
14
- "registry": "https://registry.npmjs.org/"
15
- }
16
- }
17
- }
@@ -1,46 +0,0 @@
1
- {
2
- "private": true,
3
- "name": "monorepo",
4
- "version": "0.0.0",
5
- "engines": {
6
- "yarn": ">=1.7.0 <2",
7
- "node": ">=16"
8
- },
9
- "resolutions": {
10
- "**/@types/node": "18"
11
- },
12
- "devDependencies": {
13
- "lerna": "^5.6.2",
14
- "typedoc": "^0.23.21",
15
- "typedoc-plugin-external-module-map": "~1.3.2",
16
- "typedoc-plugin-remove-references": "^0.0.6",
17
- "chai": "4.3.4",
18
- "chai-spies": "1.0.0",
19
- "chai-string": "^1.4.0"
20
- },
21
- "scripts": {
22
- "bootstrap": "lerna bootstrap",
23
- "prepare": "yarn run prepare:references && yarn run prepare:build",
24
- "prepare:references": "node scripts/compile-references.js",
25
- "prepare:build": "yarn build && yarn run lint",
26
- "build": "tsc -b configs/root-compilation.tsconfig.json",
27
- "watch": "tsc -b configs/root-compilation.tsconfig.json -w",
28
- "clean": "yarn lint:clean && lerna run clean",
29
- "build:clean": "lerna run prepare",
30
- "lint": "lerna run lint",
31
- "lint:clean": "rimraf .eslintcache",
32
- "lint:oneshot": "node --max-old-space-size=4096 node_modules/eslint/bin/eslint.js --cache=true \"{dev-packages,packages,examples}/**/*.{ts,tsx}\"",
33
- "docs": "rimraf gh-pages/docs/next && typedoc --tsconfig tsconfig.json --options configs/typedoc.json .",
34
- "test": "yarn test:references && yarn test:app",
35
- "test:references": "node scripts/compile-references --dry-run",
36
- "test:app": "lerna run test --scope \"@app/*!(-app)\" --stream --concurrency=1",
37
- "publish": "yarn && yarn test && yarn publish:latest",
38
- "publish:latest": "lerna publish --exact --ignore-scripts --yes --no-push && yarn -s publish:check",
39
- "publish:next": "lerna publish preminor --exact --ignore-scripts --canary --preid next --dist-tag next --no-git-reset --no-git-tag-version --no-push --ignore-scripts --yes && yarn publish:check",
40
- "publish:check": "node scripts/check-publish.js"
41
- },
42
- "workspaces": [
43
- "packages/*",
44
- "apps/*"
45
- ]
46
- }
@@ -1,10 +0,0 @@
1
- /** @type {import('eslint').Linter.Config} */
2
- module.exports = {
3
- extends: [
4
- require.resolve('@celljs/style-guide/eslint/build')
5
- ],
6
- parserOptions: {
7
- tsconfigRootDir: __dirname,
8
- project: 'tsconfig.json'
9
- }
10
- };
@@ -1 +0,0 @@
1
- # App - Core Component
File without changes
@@ -1,40 +0,0 @@
1
- {
2
- "name": "@app/core",
3
- "version": "0.0.0",
4
- "description": "",
5
- "main": "lib/common/index.js",
6
- "typings": "lib/common/index.d.ts",
7
- "dependencies": {
8
- "@celljs/core": "2.42.0"
9
- },
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "keywords": [
14
- "cell-component"
15
- ],
16
- "license": "MIT",
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/xxx/app.git"
20
- },
21
- "bugs": {
22
- "url": "https://github.com/xxx/app/issues"
23
- },
24
- "homepage": "https://github.com/xxx/app",
25
- "files": [
26
- "lib",
27
- "src",
28
- "cell.yml"
29
- ],
30
- "scripts": {
31
- "lint": "cell-component lint",
32
- "build": "cell-component build",
33
- "watch": "cell-component watch",
34
- "clean": "cell-component clean",
35
- "test": "cell-component test:js"
36
- },
37
- "devDependencies": {
38
- "@celljs/component": "2.42.0"
39
- }
40
- }
@@ -1,4 +0,0 @@
1
- import { autoBind } from '@celljs/core';
2
- import './index';
3
-
4
- export default autoBind();
@@ -1,4 +0,0 @@
1
- import { autoBind } from '@celljs/core';
2
- import './index';
3
-
4
- export default autoBind();
@@ -1,4 +0,0 @@
1
- import { autoBind } from '@celljs/core';
2
- import './index';
3
-
4
- export default autoBind();
@@ -1,4 +0,0 @@
1
- describe('core package', () => {
2
-
3
- it('support code coverage statistics', () => {});
4
- });
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "@celljs/style-guide/typescript",
3
- "compilerOptions": {
4
- "composite": true,
5
- "rootDir": "src",
6
- "outDir": "lib",
7
- "baseUrl": "."
8
- },
9
- "include": [
10
- "src"
11
- ],
12
- "references": []
13
- }
@@ -1,40 +0,0 @@
1
- // @ts-check
2
-
3
- const path = require('path');
4
- const chalk = require('chalk');
5
- const cp = require('child_process');
6
- const fs = require('fs');
7
-
8
- checkPublish().catch(error => {
9
- console.error(error);
10
- process.exitCode = 1;
11
- });
12
-
13
- async function checkPublish() {
14
- const workspaces = JSON.parse(cp.execSync('yarn --silent workspaces info').toString());
15
- await Promise.all(Object.values(workspaces).map(async workspace => {
16
- const packagePath = path.resolve(workspace.location, 'package.json');
17
- const pck = JSON.parse(await fs.promises.readFile(packagePath, 'utf8'));
18
- if (!pck.private) {
19
- const pckName = `${pck.name}@${pck.version}`;
20
- const npmViewOutput = await new Promise(
21
- resolve => cp.exec(`npm view ${pckName} version --json`,
22
- (error, stdout, stderr) => {
23
- if (error) {
24
- console.error(error);
25
- resolve('');
26
- } else {
27
- resolve(stdout.trim());
28
- }
29
- }
30
- )
31
- );
32
- if (npmViewOutput) {
33
- console.info(`${pckName}: published`);
34
- } else {
35
- console.error(`(${chalk.red('ERR')}) ${pckName}: ${chalk.red('NOT')} published`);
36
- process.exitCode = 1;
37
- }
38
- }
39
- }));
40
- }
@@ -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,3 +0,0 @@
1
- {
2
- "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true
3
- }