parent
							
								
									bb204b8f95
								
							
						
					
					
						commit
						ec406f25ef
					
				
							
								
								
									
										43
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								package.json
									
									
									
									
									
								
							@ -1,36 +1,37 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "nocobase",
 | 
			
		||||
  "name": "tachybase",
 | 
			
		||||
  "version": "0.21.6",
 | 
			
		||||
  "private": true,
 | 
			
		||||
  "license": "Apache-2.0",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "nocobase build",
 | 
			
		||||
    "build:p": "nocobase build --no-dts",
 | 
			
		||||
    "build": "tachybase build",
 | 
			
		||||
    "build:p": "tachybase build --no-dts",
 | 
			
		||||
    "changelog": "auto-changelog -p -t keepachangelog",
 | 
			
		||||
    "clean": "nocobase clean",
 | 
			
		||||
    "dev": "nocobase dev",
 | 
			
		||||
    "dev-server": "nocobase dev --server",
 | 
			
		||||
    "doc": "nocobase doc",
 | 
			
		||||
    "doc:cn": "nocobase doc --lang=zh-CN",
 | 
			
		||||
    "e2e": "nocobase e2e",
 | 
			
		||||
    "clean": "tachybase clean",
 | 
			
		||||
    "dev": "tachybase dev",
 | 
			
		||||
    "dev-server": "tachybase dev --server",
 | 
			
		||||
    "doc": "tachybase doc",
 | 
			
		||||
    "doc:cn": "tachybase doc --lang=zh-CN",
 | 
			
		||||
    "e2e": "tachybase e2e",
 | 
			
		||||
    "preinstall": "npx only-allow pnpm",
 | 
			
		||||
    "postinstall": "nocobase postinstall",
 | 
			
		||||
    "postinstall": "tachybase postinstall",
 | 
			
		||||
    "lint": "eslint .",
 | 
			
		||||
    "nocobase": "nocobase",
 | 
			
		||||
    "pm": "nocobase pm",
 | 
			
		||||
    "pm2": "nocobase pm2",
 | 
			
		||||
    "pm": "tachybase pm",
 | 
			
		||||
    "pm2": "tachybase pm2",
 | 
			
		||||
    "prepare": "husky",
 | 
			
		||||
    "run:example": "tsx -r dotenv/config -r tsconfig-paths/register ./examples/index.ts",
 | 
			
		||||
    "start": "nocobase start",
 | 
			
		||||
    "start": "tachybase start",
 | 
			
		||||
    "tachybase": "tachybase",
 | 
			
		||||
    "tag:c": "changeset",
 | 
			
		||||
    "tag:p": "changeset",
 | 
			
		||||
    "tag:v": "changeset version",
 | 
			
		||||
    "tar": "nocobase tar",
 | 
			
		||||
    "tc": "nocobase test:client",
 | 
			
		||||
    "test": "nocobase test",
 | 
			
		||||
    "test:client": "nocobase test:client",
 | 
			
		||||
    "test:server": "nocobase test:server",
 | 
			
		||||
    "ts": "nocobase test:server"
 | 
			
		||||
    "tar": "tachybase tar",
 | 
			
		||||
    "tb": "tachybase",
 | 
			
		||||
    "tc": "tachybase test:client",
 | 
			
		||||
    "test": "tachybase test",
 | 
			
		||||
    "test:client": "tachybase test:client",
 | 
			
		||||
    "test:server": "tachybase test:server",
 | 
			
		||||
    "ts": "tachybase test:server"
 | 
			
		||||
  },
 | 
			
		||||
  "lint-staged": {
 | 
			
		||||
    "*.{js,json,sql}": [
 | 
			
		||||
@ -50,9 +51,9 @@
 | 
			
		||||
    "@commitlint/config-conventional": "^16.0.0",
 | 
			
		||||
    "@commitlint/prompt-cli": "^16.1.0",
 | 
			
		||||
    "@nocobase/build": "workspace:*",
 | 
			
		||||
    "@nocobase/cli": "workspace:*",
 | 
			
		||||
    "@nocobase/preset-nocobase": "workspace:*",
 | 
			
		||||
    "@nocobase/test": "workspace:*",
 | 
			
		||||
    "@tachybase/cli": "workspace:*",
 | 
			
		||||
    "@types/react": "^18.2.73",
 | 
			
		||||
    "@types/react-dom": "^18.2.23",
 | 
			
		||||
    "auto-changelog": "^2.4.0",
 | 
			
		||||
 | 
			
		||||
@ -1,201 +0,0 @@
 | 
			
		||||
                                 Apache License
 | 
			
		||||
                           Version 2.0, January 2004
 | 
			
		||||
                        http://www.apache.org/licenses/
 | 
			
		||||
 | 
			
		||||
   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
 | 
			
		||||
 | 
			
		||||
   1. Definitions.
 | 
			
		||||
 | 
			
		||||
      "License" shall mean the terms and conditions for use, reproduction,
 | 
			
		||||
      and distribution as defined by Sections 1 through 9 of this document.
 | 
			
		||||
 | 
			
		||||
      "Licensor" shall mean the copyright owner or entity authorized by
 | 
			
		||||
      the copyright owner that is granting the License.
 | 
			
		||||
 | 
			
		||||
      "Legal Entity" shall mean the union of the acting entity and all
 | 
			
		||||
      other entities that control, are controlled by, or are under common
 | 
			
		||||
      control with that entity. For the purposes of this definition,
 | 
			
		||||
      "control" means (i) the power, direct or indirect, to cause the
 | 
			
		||||
      direction or management of such entity, whether by contract or
 | 
			
		||||
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
 | 
			
		||||
      outstanding shares, or (iii) beneficial ownership of such entity.
 | 
			
		||||
 | 
			
		||||
      "You" (or "Your") shall mean an individual or Legal Entity
 | 
			
		||||
      exercising permissions granted by this License.
 | 
			
		||||
 | 
			
		||||
      "Source" form shall mean the preferred form for making modifications,
 | 
			
		||||
      including but not limited to software source code, documentation
 | 
			
		||||
      source, and configuration files.
 | 
			
		||||
 | 
			
		||||
      "Object" form shall mean any form resulting from mechanical
 | 
			
		||||
      transformation or translation of a Source form, including but
 | 
			
		||||
      not limited to compiled object code, generated documentation,
 | 
			
		||||
      and conversions to other media types.
 | 
			
		||||
 | 
			
		||||
      "Work" shall mean the work of authorship, whether in Source or
 | 
			
		||||
      Object form, made available under the License, as indicated by a
 | 
			
		||||
      copyright notice that is included in or attached to the work
 | 
			
		||||
      (an example is provided in the Appendix below).
 | 
			
		||||
 | 
			
		||||
      "Derivative Works" shall mean any work, whether in Source or Object
 | 
			
		||||
      form, that is based on (or derived from) the Work and for which the
 | 
			
		||||
      editorial revisions, annotations, elaborations, or other modifications
 | 
			
		||||
      represent, as a whole, an original work of authorship. For the purposes
 | 
			
		||||
      of this License, Derivative Works shall not include works that remain
 | 
			
		||||
      separable from, or merely link (or bind by name) to the interfaces of,
 | 
			
		||||
      the Work and Derivative Works thereof.
 | 
			
		||||
 | 
			
		||||
      "Contribution" shall mean any work of authorship, including
 | 
			
		||||
      the original version of the Work and any modifications or additions
 | 
			
		||||
      to that Work or Derivative Works thereof, that is intentionally
 | 
			
		||||
      submitted to Licensor for inclusion in the Work by the copyright owner
 | 
			
		||||
      or by an individual or Legal Entity authorized to submit on behalf of
 | 
			
		||||
      the copyright owner. For the purposes of this definition, "submitted"
 | 
			
		||||
      means any form of electronic, verbal, or written communication sent
 | 
			
		||||
      to the Licensor or its representatives, including but not limited to
 | 
			
		||||
      communication on electronic mailing lists, source code control systems,
 | 
			
		||||
      and issue tracking systems that are managed by, or on behalf of, the
 | 
			
		||||
      Licensor for the purpose of discussing and improving the Work, but
 | 
			
		||||
      excluding communication that is conspicuously marked or otherwise
 | 
			
		||||
      designated in writing by the copyright owner as "Not a Contribution."
 | 
			
		||||
 | 
			
		||||
      "Contributor" shall mean Licensor and any individual or Legal Entity
 | 
			
		||||
      on behalf of whom a Contribution has been received by Licensor and
 | 
			
		||||
      subsequently incorporated within the Work.
 | 
			
		||||
 | 
			
		||||
   2. Grant of Copyright License. Subject to the terms and conditions of
 | 
			
		||||
      this License, each Contributor hereby grants to You a perpetual,
 | 
			
		||||
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
 | 
			
		||||
      copyright license to reproduce, prepare Derivative Works of,
 | 
			
		||||
      publicly display, publicly perform, sublicense, and distribute the
 | 
			
		||||
      Work and such Derivative Works in Source or Object form.
 | 
			
		||||
 | 
			
		||||
   3. Grant of Patent License. Subject to the terms and conditions of
 | 
			
		||||
      this License, each Contributor hereby grants to You a perpetual,
 | 
			
		||||
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
 | 
			
		||||
      (except as stated in this section) patent license to make, have made,
 | 
			
		||||
      use, offer to sell, sell, import, and otherwise transfer the Work,
 | 
			
		||||
      where such license applies only to those patent claims licensable
 | 
			
		||||
      by such Contributor that are necessarily infringed by their
 | 
			
		||||
      Contribution(s) alone or by combination of their Contribution(s)
 | 
			
		||||
      with the Work to which such Contribution(s) was submitted. If You
 | 
			
		||||
      institute patent litigation against any entity (including a
 | 
			
		||||
      cross-claim or counterclaim in a lawsuit) alleging that the Work
 | 
			
		||||
      or a Contribution incorporated within the Work constitutes direct
 | 
			
		||||
      or contributory patent infringement, then any patent licenses
 | 
			
		||||
      granted to You under this License for that Work shall terminate
 | 
			
		||||
      as of the date such litigation is filed.
 | 
			
		||||
 | 
			
		||||
   4. Redistribution. You may reproduce and distribute copies of the
 | 
			
		||||
      Work or Derivative Works thereof in any medium, with or without
 | 
			
		||||
      modifications, and in Source or Object form, provided that You
 | 
			
		||||
      meet the following conditions:
 | 
			
		||||
 | 
			
		||||
      (a) You must give any other recipients of the Work or
 | 
			
		||||
          Derivative Works a copy of this License; and
 | 
			
		||||
 | 
			
		||||
      (b) You must cause any modified files to carry prominent notices
 | 
			
		||||
          stating that You changed the files; and
 | 
			
		||||
 | 
			
		||||
      (c) You must retain, in the Source form of any Derivative Works
 | 
			
		||||
          that You distribute, all copyright, patent, trademark, and
 | 
			
		||||
          attribution notices from the Source form of the Work,
 | 
			
		||||
          excluding those notices that do not pertain to any part of
 | 
			
		||||
          the Derivative Works; and
 | 
			
		||||
 | 
			
		||||
      (d) If the Work includes a "NOTICE" text file as part of its
 | 
			
		||||
          distribution, then any Derivative Works that You distribute must
 | 
			
		||||
          include a readable copy of the attribution notices contained
 | 
			
		||||
          within such NOTICE file, excluding those notices that do not
 | 
			
		||||
          pertain to any part of the Derivative Works, in at least one
 | 
			
		||||
          of the following places: within a NOTICE text file distributed
 | 
			
		||||
          as part of the Derivative Works; within the Source form or
 | 
			
		||||
          documentation, if provided along with the Derivative Works; or,
 | 
			
		||||
          within a display generated by the Derivative Works, if and
 | 
			
		||||
          wherever such third-party notices normally appear. The contents
 | 
			
		||||
          of the NOTICE file are for informational purposes only and
 | 
			
		||||
          do not modify the License. You may add Your own attribution
 | 
			
		||||
          notices within Derivative Works that You distribute, alongside
 | 
			
		||||
          or as an addendum to the NOTICE text from the Work, provided
 | 
			
		||||
          that such additional attribution notices cannot be construed
 | 
			
		||||
          as modifying the License.
 | 
			
		||||
 | 
			
		||||
      You may add Your own copyright statement to Your modifications and
 | 
			
		||||
      may provide additional or different license terms and conditions
 | 
			
		||||
      for use, reproduction, or distribution of Your modifications, or
 | 
			
		||||
      for any such Derivative Works as a whole, provided Your use,
 | 
			
		||||
      reproduction, and distribution of the Work otherwise complies with
 | 
			
		||||
      the conditions stated in this License.
 | 
			
		||||
 | 
			
		||||
   5. Submission of Contributions. Unless You explicitly state otherwise,
 | 
			
		||||
      any Contribution intentionally submitted for inclusion in the Work
 | 
			
		||||
      by You to the Licensor shall be under the terms and conditions of
 | 
			
		||||
      this License, without any additional terms or conditions.
 | 
			
		||||
      Notwithstanding the above, nothing herein shall supersede or modify
 | 
			
		||||
      the terms of any separate license agreement you may have executed
 | 
			
		||||
      with Licensor regarding such Contributions.
 | 
			
		||||
 | 
			
		||||
   6. Trademarks. This License does not grant permission to use the trade
 | 
			
		||||
      names, trademarks, service marks, or product names of the Licensor,
 | 
			
		||||
      except as required for reasonable and customary use in describing the
 | 
			
		||||
      origin of the Work and reproducing the content of the NOTICE file.
 | 
			
		||||
 | 
			
		||||
   7. Disclaimer of Warranty. Unless required by applicable law or
 | 
			
		||||
      agreed to in writing, Licensor provides the Work (and each
 | 
			
		||||
      Contributor provides its Contributions) on an "AS IS" BASIS,
 | 
			
		||||
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 | 
			
		||||
      implied, including, without limitation, any warranties or conditions
 | 
			
		||||
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
 | 
			
		||||
      PARTICULAR PURPOSE. You are solely responsible for determining the
 | 
			
		||||
      appropriateness of using or redistributing the Work and assume any
 | 
			
		||||
      risks associated with Your exercise of permissions under this License.
 | 
			
		||||
 | 
			
		||||
   8. Limitation of Liability. In no event and under no legal theory,
 | 
			
		||||
      whether in tort (including negligence), contract, or otherwise,
 | 
			
		||||
      unless required by applicable law (such as deliberate and grossly
 | 
			
		||||
      negligent acts) or agreed to in writing, shall any Contributor be
 | 
			
		||||
      liable to You for damages, including any direct, indirect, special,
 | 
			
		||||
      incidental, or consequential damages of any character arising as a
 | 
			
		||||
      result of this License or out of the use or inability to use the
 | 
			
		||||
      Work (including but not limited to damages for loss of goodwill,
 | 
			
		||||
      work stoppage, computer failure or malfunction, or any and all
 | 
			
		||||
      other commercial damages or losses), even if such Contributor
 | 
			
		||||
      has been advised of the possibility of such damages.
 | 
			
		||||
 | 
			
		||||
   9. Accepting Warranty or Additional Liability. While redistributing
 | 
			
		||||
      the Work or Derivative Works thereof, You may choose to offer,
 | 
			
		||||
      and charge a fee for, acceptance of support, warranty, indemnity,
 | 
			
		||||
      or other liability obligations and/or rights consistent with this
 | 
			
		||||
      License. However, in accepting such obligations, You may act only
 | 
			
		||||
      on Your own behalf and on Your sole responsibility, not on behalf
 | 
			
		||||
      of any other Contributor, and only if You agree to indemnify,
 | 
			
		||||
      defend, and hold each Contributor harmless for any liability
 | 
			
		||||
      incurred by, or claims asserted against, such Contributor by reason
 | 
			
		||||
      of your accepting any such warranty or additional liability.
 | 
			
		||||
 | 
			
		||||
   END OF TERMS AND CONDITIONS
 | 
			
		||||
 | 
			
		||||
   APPENDIX: How to apply the Apache License to your work.
 | 
			
		||||
 | 
			
		||||
      To apply the Apache License to your work, attach the following
 | 
			
		||||
      boilerplate notice, with the fields enclosed by brackets "[]"
 | 
			
		||||
      replaced with your own identifying information. (Don't include
 | 
			
		||||
      the brackets!)  The text should be enclosed in the appropriate
 | 
			
		||||
      comment syntax for the file format. We also recommend that a
 | 
			
		||||
      file or class name and description of purpose be included on the
 | 
			
		||||
      same "printed page" as the copyright notice for easier
 | 
			
		||||
      identification within third-party archives.
 | 
			
		||||
 | 
			
		||||
   Copyright [yyyy] [name of copyright owner]
 | 
			
		||||
 | 
			
		||||
   Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
   you may not use this file except in compliance with the License.
 | 
			
		||||
   You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
       http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
   Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
   distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
   See the License for the specific language governing permissions and
 | 
			
		||||
   limitations under the License.
 | 
			
		||||
							
								
								
									
										2
									
								
								packages/core/cli/bin/cli.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										2
									
								
								packages/core/cli/bin/cli.js
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
#!/usr/bin/env node
 | 
			
		||||
import('../dist/cli.mjs');
 | 
			
		||||
@ -1,31 +0,0 @@
 | 
			
		||||
#!/usr/bin/env node
 | 
			
		||||
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
const { initEnv, genTsConfigPaths } = require('../src/util');
 | 
			
		||||
 | 
			
		||||
initEnv();
 | 
			
		||||
genTsConfigPaths();
 | 
			
		||||
 | 
			
		||||
if (require('semver').satisfies(process.version, '<16')) {
 | 
			
		||||
  console.error(chalk.red('[nocobase cli]: Node.js version must be >= 16'));
 | 
			
		||||
  process.exit(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// if (require('semver').satisfies(process.version, '>16') && !process.env.UNSET_NODE_OPTIONS) {
 | 
			
		||||
//   if (process.env.NODE_OPTIONS) {
 | 
			
		||||
//     let opts = process.env.NODE_OPTIONS;
 | 
			
		||||
//     if (!opts.includes('--openssl-legacy-provider')) {
 | 
			
		||||
//       opts = opts + ' --openssl-legacy-provider';
 | 
			
		||||
//     }
 | 
			
		||||
//     if (!opts.includes('--no-experimental-fetch')) {
 | 
			
		||||
//       opts = opts + ' --no-experimental-fetch';
 | 
			
		||||
//     }
 | 
			
		||||
//     process.env.NODE_OPTIONS = opts;
 | 
			
		||||
//   } else {
 | 
			
		||||
//     process.env.NODE_OPTIONS = '--openssl-legacy-provider --no-experimental-fetch';
 | 
			
		||||
//   }
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
const cli = require('../src/cli');
 | 
			
		||||
 | 
			
		||||
cli.parse(process.argv);
 | 
			
		||||
@ -1,37 +1,53 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "@nocobase/cli",
 | 
			
		||||
  "name": "@tachybase/cli",
 | 
			
		||||
  "version": "0.21.6",
 | 
			
		||||
  "description": "",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "git+https://github.com/nocobase/nocobase.git",
 | 
			
		||||
    "directory": "packages/core/cli"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "Apache-2.0",
 | 
			
		||||
  "type": "module",
 | 
			
		||||
  "main": "./src/index.js",
 | 
			
		||||
  "bin": {
 | 
			
		||||
    "nocobase": "./bin/index.js"
 | 
			
		||||
    "tachybase": "./bin/cli.js"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "rimraf dist && rollup -c",
 | 
			
		||||
    "dev": "rollup -c --watch --watch.include 'src/**' -m inline",
 | 
			
		||||
    "prepare": "rimraf dist && BUILD_NO_DTS=1 rollup -c --silent",
 | 
			
		||||
    "typecheck": "tsc --noEmit"
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@nocobase/app": "workspace:*",
 | 
			
		||||
    "@nocobase/utils": "workspace:*",
 | 
			
		||||
    "@types/fs-extra": "^11.0.1",
 | 
			
		||||
    "@umijs/utils": "3.5.20",
 | 
			
		||||
    "chalk": "^4.1.1",
 | 
			
		||||
    "commander": "^9.2.0",
 | 
			
		||||
    "chalk": "^5.3.0",
 | 
			
		||||
    "commander": "^12.0.0",
 | 
			
		||||
    "dotenv": "^16.0.0",
 | 
			
		||||
    "execa": "^5.1.1",
 | 
			
		||||
    "execa": "^8.0.1",
 | 
			
		||||
    "fast-glob": "^3.3.1",
 | 
			
		||||
    "fs-extra": "^11.1.1",
 | 
			
		||||
    "lodash": "^4.17.21",
 | 
			
		||||
    "p-all": "3.0.0",
 | 
			
		||||
    "pm2": "^5.2.0",
 | 
			
		||||
    "portfinder": "^1.0.28",
 | 
			
		||||
    "semver": "^7.6.0",
 | 
			
		||||
    "serve": "^13.0.2",
 | 
			
		||||
    "tree-kill": "^1.2.2",
 | 
			
		||||
    "tsx": "^4.7.2"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@nocobase/devtools": "workspace:*"
 | 
			
		||||
    "@nocobase/devtools": "workspace:*",
 | 
			
		||||
    "@rollup/plugin-commonjs": "^25.0.7",
 | 
			
		||||
    "@rollup/plugin-json": "^6.1.0",
 | 
			
		||||
    "@rollup/plugin-node-resolve": "^15.2.3",
 | 
			
		||||
    "@types/fs-extra": "^11.0.4",
 | 
			
		||||
    "@types/lodash": "^4.17.0",
 | 
			
		||||
    "@types/node": "^20.12.7",
 | 
			
		||||
    "@types/semver": "^7.5.8",
 | 
			
		||||
    "rimraf": "^5.0.5",
 | 
			
		||||
    "rollup": "^4.14.1",
 | 
			
		||||
    "rollup-plugin-dts": "^6.1.0",
 | 
			
		||||
    "rollup-plugin-esbuild": "^6.1.1",
 | 
			
		||||
    "vite": "^5.2.8"
 | 
			
		||||
  },
 | 
			
		||||
  "gitHead": "d0b4efe4be55f8c79a98a331d99d9f8cf99021a1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										74
									
								
								packages/core/cli/rollup.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								packages/core/cli/rollup.config.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,74 @@
 | 
			
		||||
import { builtinModules, createRequire } from 'node:module';
 | 
			
		||||
import esbuild from 'rollup-plugin-esbuild';
 | 
			
		||||
import process from 'node:process';
 | 
			
		||||
import dts from 'rollup-plugin-dts';
 | 
			
		||||
import resolve from '@rollup/plugin-node-resolve';
 | 
			
		||||
import commonjs from '@rollup/plugin-commonjs';
 | 
			
		||||
import json from '@rollup/plugin-json';
 | 
			
		||||
import { defineConfig } from 'rollup';
 | 
			
		||||
 | 
			
		||||
const require = createRequire(import.meta.url);
 | 
			
		||||
const pkg = require('./package.json');
 | 
			
		||||
 | 
			
		||||
const entries = {
 | 
			
		||||
  cli: 'src/cli.ts',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const external = [
 | 
			
		||||
  ...builtinModules,
 | 
			
		||||
  ...Object.keys(pkg.dependencies || {}),
 | 
			
		||||
  ...Object.keys(pkg.peerDependencies || {}),
 | 
			
		||||
  'pathe',
 | 
			
		||||
  'birpc',
 | 
			
		||||
  'vite',
 | 
			
		||||
  'node:url',
 | 
			
		||||
  'node:events',
 | 
			
		||||
  'node:vm',
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
const plugins = [
 | 
			
		||||
  resolve({
 | 
			
		||||
    preferBuiltins: true,
 | 
			
		||||
  }),
 | 
			
		||||
  json(),
 | 
			
		||||
  commonjs(),
 | 
			
		||||
  esbuild({
 | 
			
		||||
    target: 'esnext',
 | 
			
		||||
  }),
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
const configs = defineConfig([
 | 
			
		||||
  {
 | 
			
		||||
    input: entries,
 | 
			
		||||
    output: {
 | 
			
		||||
      dir: 'dist',
 | 
			
		||||
      format: 'esm',
 | 
			
		||||
      entryFileNames: '[name].mjs',
 | 
			
		||||
      chunkFileNames: 'chunk-[name].mjs',
 | 
			
		||||
    },
 | 
			
		||||
    external,
 | 
			
		||||
    plugins,
 | 
			
		||||
    onwarn,
 | 
			
		||||
  },
 | 
			
		||||
]);
 | 
			
		||||
 | 
			
		||||
if (!process.env.BUILD_NO_DTS) {
 | 
			
		||||
  configs.push({
 | 
			
		||||
    input: entries,
 | 
			
		||||
    output: {
 | 
			
		||||
      dir: 'dist',
 | 
			
		||||
      entryFileNames: '[name].d.ts',
 | 
			
		||||
      format: 'esm',
 | 
			
		||||
    },
 | 
			
		||||
    external,
 | 
			
		||||
    plugins: [dts({ respectExternal: true })],
 | 
			
		||||
    onwarn,
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default configs;
 | 
			
		||||
 | 
			
		||||
function onwarn(message) {
 | 
			
		||||
  if (['EMPTY_BUNDLE', 'CIRCULAR_DEPENDENCY'].includes(message.code)) return;
 | 
			
		||||
  console.error(message);
 | 
			
		||||
}
 | 
			
		||||
@ -1,10 +0,0 @@
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const commands = require('./commands');
 | 
			
		||||
 | 
			
		||||
const cli = new Command();
 | 
			
		||||
 | 
			
		||||
cli.version(require('../package.json').version);
 | 
			
		||||
 | 
			
		||||
commands(cli);
 | 
			
		||||
 | 
			
		||||
module.exports = cli;
 | 
			
		||||
							
								
								
									
										22
									
								
								packages/core/cli/src/cli.ts
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										22
									
								
								packages/core/cli/src/cli.ts
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
#!/usr/bin/env node
 | 
			
		||||
 | 
			
		||||
import chalk from 'chalk';
 | 
			
		||||
import { initEnv, genTsConfigPaths } from './util';
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import commands from './commands';
 | 
			
		||||
import semver from 'semver';
 | 
			
		||||
 | 
			
		||||
const cli = new Command();
 | 
			
		||||
 | 
			
		||||
cli.version((await import('../package.json')).version);
 | 
			
		||||
await commands(cli);
 | 
			
		||||
 | 
			
		||||
initEnv();
 | 
			
		||||
genTsConfigPaths();
 | 
			
		||||
 | 
			
		||||
if (semver.satisfies(process.version, '<20')) {
 | 
			
		||||
  console.error(chalk.red('[tachybase cli]: Node.js version must be >= 20'));
 | 
			
		||||
  process.exit(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cli.parse(process.argv);
 | 
			
		||||
@ -1,12 +1,12 @@
 | 
			
		||||
const { resolve } = require('path');
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { run, nodeCheck, isPackageValid, buildIndexHtml } = require('../util');
 | 
			
		||||
import { resolve } from 'path';
 | 
			
		||||
import { type Command } from 'commander';
 | 
			
		||||
import { run, nodeCheck, isPackageValid, buildIndexHtml } from '../util';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  cli
 | 
			
		||||
    .command('build')
 | 
			
		||||
    .allowUnknownOption()
 | 
			
		||||
@ -1,12 +1,11 @@
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { run, isDev } = require('../util');
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { run, isDev } from '../util';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  cli
 | 
			
		||||
    .command('clean')
 | 
			
		||||
    .allowUnknownOption()
 | 
			
		||||
@ -1,19 +1,15 @@
 | 
			
		||||
const { resolve } = require('path');
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { readFileSync, writeFileSync } = require('fs');
 | 
			
		||||
import { resolve } from 'path';
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { readFileSync, writeFileSync } from 'fs';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  cli.command('create-nginx-conf').action(async (name, options) => {
 | 
			
		||||
    const file = resolve(__dirname, '../../nocobase.conf.tpl');
 | 
			
		||||
    const data = readFileSync(file, 'utf-8');
 | 
			
		||||
    const replaced = data
 | 
			
		||||
      .replace(/\{\{cwd\}\}/g, '/app/nocobase')
 | 
			
		||||
      .replace(/\{\{publicPath\}\}/g, process.env.APP_PUBLIC_PATH)
 | 
			
		||||
      .replace(/\{\{apiPort\}\}/g, process.env.APP_PORT);
 | 
			
		||||
      .replace(/\{\{publicPath\}\}/g, process.env.APP_PUBLIC_PATH!)
 | 
			
		||||
      .replace(/\{\{apiPort\}\}/g, process.env.APP_PORT!);
 | 
			
		||||
 | 
			
		||||
    const targetFile = resolve(process.cwd(), 'storage', 'nocobase.conf');
 | 
			
		||||
    writeFileSync(targetFile, replaced);
 | 
			
		||||
@ -1,12 +1,8 @@
 | 
			
		||||
const { resolve } = require('path');
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { PluginGenerator } = require('../plugin-generator');
 | 
			
		||||
import { resolve } from 'path';
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { PluginGenerator } from '../plugin-generator';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  cli
 | 
			
		||||
    .command('create-plugin')
 | 
			
		||||
    .argument('<name>')
 | 
			
		||||
@ -1,13 +1,8 @@
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { runAppCommand, runInstall, run, postCheck, nodeCheck, promptForTs } = require('../util');
 | 
			
		||||
const { getPortPromise } = require('portfinder');
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { run, postCheck, nodeCheck, promptForTs } from '../util';
 | 
			
		||||
import { getPortPromise } from 'portfinder';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  const { APP_PACKAGE_ROOT } = process.env;
 | 
			
		||||
  cli
 | 
			
		||||
    .command('dev')
 | 
			
		||||
@ -20,8 +15,13 @@ module.exports = (cli) => {
 | 
			
		||||
    .action(async (opts) => {
 | 
			
		||||
      promptForTs();
 | 
			
		||||
      const { SERVER_TSCONFIG_PATH } = process.env;
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      process.env.IS_DEV_CMD = true;
 | 
			
		||||
 | 
			
		||||
      if (!SERVER_TSCONFIG_PATH) {
 | 
			
		||||
        throw new Error('SERVER_TSCONFIG_PATH is not set.');
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (process.argv.includes('-h') || process.argv.includes('--help')) {
 | 
			
		||||
        run('ts-node', [
 | 
			
		||||
          '-P',
 | 
			
		||||
@ -42,15 +42,19 @@ module.exports = (cli) => {
 | 
			
		||||
 | 
			
		||||
      const { APP_PORT } = process.env;
 | 
			
		||||
 | 
			
		||||
      let clientPort = APP_PORT;
 | 
			
		||||
      let serverPort;
 | 
			
		||||
      let clientPort = 0;
 | 
			
		||||
      let serverPort = 0;
 | 
			
		||||
 | 
			
		||||
      if (APP_PORT) {
 | 
			
		||||
        clientPort = Number(APP_PORT);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      nodeCheck();
 | 
			
		||||
 | 
			
		||||
      await postCheck(opts);
 | 
			
		||||
 | 
			
		||||
      if (server) {
 | 
			
		||||
        serverPort = APP_PORT;
 | 
			
		||||
        serverPort = Number(APP_PORT!);
 | 
			
		||||
      } else if (!server && !client) {
 | 
			
		||||
        serverPort = await getPortPromise({
 | 
			
		||||
          port: 1 * clientPort + 1,
 | 
			
		||||
@ -85,7 +89,7 @@ module.exports = (cli) => {
 | 
			
		||||
        const runDevServer = () => {
 | 
			
		||||
          run('tsx', argv, {
 | 
			
		||||
            env: {
 | 
			
		||||
              APP_PORT: serverPort,
 | 
			
		||||
              APP_PORT: serverPort + '',
 | 
			
		||||
            },
 | 
			
		||||
          }).catch((err) => {
 | 
			
		||||
            if (err.exitCode == 100) {
 | 
			
		||||
@ -104,7 +108,7 @@ module.exports = (cli) => {
 | 
			
		||||
        console.log('starting client', 1 * clientPort);
 | 
			
		||||
        run('umi', ['dev'], {
 | 
			
		||||
          env: {
 | 
			
		||||
            PORT: clientPort,
 | 
			
		||||
            PORT: clientPort + '',
 | 
			
		||||
            APP_ROOT: `${APP_PACKAGE_ROOT}/client`,
 | 
			
		||||
            WEBSOCKET_URL:
 | 
			
		||||
              process.env.WEBSOCKET_URL ||
 | 
			
		||||
@ -1,67 +0,0 @@
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { resolve, isAbsolute } = require('path');
 | 
			
		||||
const { run, isDev } = require('../util');
 | 
			
		||||
const fs = require('fs-extra');
 | 
			
		||||
const glob = require('fast-glob');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
  cli
 | 
			
		||||
    .command('doc')
 | 
			
		||||
    .argument('[dev|build|serve]')
 | 
			
		||||
    .argument('[packages]')
 | 
			
		||||
    .option('--lang [lang]')
 | 
			
		||||
    .allowUnknownOption()
 | 
			
		||||
    .action((command, pkg, options) => {
 | 
			
		||||
      if (!isDev()) {
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // 指定项目目录
 | 
			
		||||
      let cwd = process.cwd();
 | 
			
		||||
      if (command === undefined && pkg === undefined) {
 | 
			
		||||
        command = 'dev';
 | 
			
		||||
      } else if (!['dev', 'build', 'serve'].includes(command) && pkg === undefined) {
 | 
			
		||||
        pkg = command;
 | 
			
		||||
        command = 'dev';
 | 
			
		||||
        cwd = resolve(process.cwd(), 'packages', pkg);
 | 
			
		||||
      }
 | 
			
		||||
      if (pkg !== undefined) {
 | 
			
		||||
        process.env.APP_ROOT = `packages/${pkg}`;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // 删除 tmp 目录
 | 
			
		||||
      const tmpDir = glob.sync(
 | 
			
		||||
        ['.dumi/tmp', '.dumi/tmp-production', 'packages/*/*/.dumi/tmp', 'packages/*/*.dumi/tmp-production'],
 | 
			
		||||
        {
 | 
			
		||||
          cwd: process.cwd(),
 | 
			
		||||
          onlyDirectories: true,
 | 
			
		||||
        },
 | 
			
		||||
      );
 | 
			
		||||
      tmpDir.forEach((dir) => {
 | 
			
		||||
        fs.removeSync(dir);
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      // 设置语言
 | 
			
		||||
      process.env.DOC_LANG = options.lang || 'en-US';
 | 
			
		||||
 | 
			
		||||
      if (command === 'serve') {
 | 
			
		||||
        // 如果是多语言,则需要进入内部,如果不是多语言,则直接进入 docs/dist
 | 
			
		||||
        let dir = resolve(cwd, 'docs/dist', process.env.DOC_LANG);
 | 
			
		||||
        if (!fs.existsSync(dir)) {
 | 
			
		||||
          dir = resolve(cwd, 'docs/dist');
 | 
			
		||||
        }
 | 
			
		||||
        run('serve', [dir]);
 | 
			
		||||
      } else {
 | 
			
		||||
        run('dumi', [command], {
 | 
			
		||||
          env: {
 | 
			
		||||
            APP_ROOT: process.env.APP_ROOT || './packages/core/client',
 | 
			
		||||
            DOC_LANG: process.env.DOC_LANG,
 | 
			
		||||
          },
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
@ -1,11 +1,11 @@
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { run, isPortReachable } = require('../util');
 | 
			
		||||
const { execSync } = require('node:child_process');
 | 
			
		||||
const axios = require('axios');
 | 
			
		||||
const { pTest } = require('./p-test');
 | 
			
		||||
const os = require('os');
 | 
			
		||||
const treeKill = require('tree-kill');
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { run, isPortReachable } from '../util';
 | 
			
		||||
import { execSync } from 'node:child_process';
 | 
			
		||||
import axios from 'axios';
 | 
			
		||||
import { pTest } from './p-test';
 | 
			
		||||
import { cpus } from 'os';
 | 
			
		||||
import treeKill from 'tree-kill';
 | 
			
		||||
import chalk from 'chalk';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 检查服务是否启动成功
 | 
			
		||||
@ -19,12 +19,7 @@ const checkServer = async (duration = 1000, max = 60 * 10) => {
 | 
			
		||||
        return reject(new Error('Server start timeout.'));
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // if (!(await checkPort(PORT))) {
 | 
			
		||||
      //   return;
 | 
			
		||||
      // }
 | 
			
		||||
 | 
			
		||||
      const url = `${process.env.APP_BASE_URL}/api/__health_check`;
 | 
			
		||||
      // console.log('url', url);
 | 
			
		||||
 | 
			
		||||
      axios
 | 
			
		||||
        .get(url)
 | 
			
		||||
@ -84,13 +79,13 @@ async function appReady() {
 | 
			
		||||
 | 
			
		||||
async function runApp(options = {}) {
 | 
			
		||||
  console.log('installing...');
 | 
			
		||||
  await run('nocobase', ['install', '-f']);
 | 
			
		||||
  if (await isPortReachable(process.env.APP_PORT)) {
 | 
			
		||||
  await run('tachybase', ['install', '-f']);
 | 
			
		||||
  if (await isPortReachable(process.env.APP_PORT!)) {
 | 
			
		||||
    console.log('app started');
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  console.log('starting...');
 | 
			
		||||
  run('nocobase', [process.env.APP_ENV === 'production' ? 'start' : 'dev'], options);
 | 
			
		||||
  run('tachybase', [process.env.APP_ENV === 'production' ? 'start' : 'dev'], options);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
process.on('SIGINT', async () => {
 | 
			
		||||
@ -112,12 +107,14 @@ const runCodegenSync = () => {
 | 
			
		||||
  try {
 | 
			
		||||
    execSync(
 | 
			
		||||
      `npx playwright codegen --load-storage=storage/playwright/.auth/codegen.auth.json ${process.env.APP_BASE_URL} --save-storage=storage/playwright/.auth/codegen.auth.json`,
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      commonConfig,
 | 
			
		||||
    );
 | 
			
		||||
  } catch (err) {
 | 
			
		||||
  } catch (err: any) {
 | 
			
		||||
    if (err.message.includes('auth.json')) {
 | 
			
		||||
      execSync(
 | 
			
		||||
        `npx playwright codegen ${process.env.APP_BASE_URL} --save-storage=storage/playwright/.auth/codegen.auth.json`,
 | 
			
		||||
        // @ts-ignore
 | 
			
		||||
        commonConfig,
 | 
			
		||||
      );
 | 
			
		||||
    } else {
 | 
			
		||||
@ -152,11 +149,7 @@ const filterArgv = () => {
 | 
			
		||||
  return argv;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  const e2e = cli.command('e2e').hook('preAction', () => {
 | 
			
		||||
    if (process.env.APP_BASE_URL) {
 | 
			
		||||
      process.env.APP_BASE_URL = process.env.APP_BASE_URL.replace('localhost', '127.0.0.1');
 | 
			
		||||
@ -172,6 +165,7 @@ module.exports = (cli) => {
 | 
			
		||||
    .option('--build')
 | 
			
		||||
    .option('--production')
 | 
			
		||||
    .action(async (options) => {
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      process.env.__E2E__ = true;
 | 
			
		||||
      if (options.production) {
 | 
			
		||||
        process.env.APP_ENV = 'production';
 | 
			
		||||
@ -181,6 +175,7 @@ module.exports = (cli) => {
 | 
			
		||||
        await run('pnpm', ['build']);
 | 
			
		||||
      }
 | 
			
		||||
      if (options.skipReporter) {
 | 
			
		||||
        // @ts-ignore
 | 
			
		||||
        process.env.PLAYWRIGHT_SKIP_REPORTER = true;
 | 
			
		||||
      }
 | 
			
		||||
      if (options.url) {
 | 
			
		||||
@ -217,6 +212,7 @@ module.exports = (cli) => {
 | 
			
		||||
    .option('--build')
 | 
			
		||||
    .option('--port [port]')
 | 
			
		||||
    .action(async (options) => {
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      process.env.__E2E__ = true;
 | 
			
		||||
      if (options.build) {
 | 
			
		||||
        await run('pnpm', ['build']);
 | 
			
		||||
@ -231,7 +227,7 @@ module.exports = (cli) => {
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
  e2e.command('reinstall-app').action(async (options) => {
 | 
			
		||||
    await run('nocobase', ['install', '-f'], options);
 | 
			
		||||
    await run('tachybase', ['install', '-f'], options);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  e2e.command('install-deps').action(async () => {
 | 
			
		||||
@ -242,7 +238,7 @@ module.exports = (cli) => {
 | 
			
		||||
    .command('p-test')
 | 
			
		||||
    .option('--stop-on-error')
 | 
			
		||||
    .option('--build')
 | 
			
		||||
    .option('--concurrency [concurrency]', '', os.cpus().length)
 | 
			
		||||
    .option('--concurrency [concurrency]', '', cpus().length + '')
 | 
			
		||||
    .option(
 | 
			
		||||
      '--match [match]',
 | 
			
		||||
      'Only the files matching one of these patterns are executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.',
 | 
			
		||||
@ -250,6 +246,7 @@ module.exports = (cli) => {
 | 
			
		||||
    )
 | 
			
		||||
    .option('--ignore [ignore]', 'Skip tests that match the pattern. Strings are treated as glob patterns.', undefined)
 | 
			
		||||
    .action(async (options) => {
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      process.env.__E2E__ = true;
 | 
			
		||||
      if (options.build) {
 | 
			
		||||
        process.env.APP_ENV = 'production';
 | 
			
		||||
@ -1,11 +1,7 @@
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { run, isDev, isProd, promptForTs } = require('../util');
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { run, isDev, isProd, promptForTs } from '../util';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env;
 | 
			
		||||
  cli
 | 
			
		||||
    .allowUnknownOption()
 | 
			
		||||
@ -16,7 +12,7 @@ module.exports = (cli) => {
 | 
			
		||||
        promptForTs();
 | 
			
		||||
        run('tsx', [
 | 
			
		||||
          '--tsconfig',
 | 
			
		||||
          SERVER_TSCONFIG_PATH,
 | 
			
		||||
          SERVER_TSCONFIG_PATH ?? '',
 | 
			
		||||
          '-r',
 | 
			
		||||
          'tsconfig-paths/register',
 | 
			
		||||
          `${APP_PACKAGE_ROOT}/src/index.ts`,
 | 
			
		||||
@ -1,27 +0,0 @@
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { isPackageValid, generateAppDir } = require('../util');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
  generateAppDir();
 | 
			
		||||
  require('./global')(cli);
 | 
			
		||||
  require('./create-nginx-conf')(cli);
 | 
			
		||||
  require('./build')(cli);
 | 
			
		||||
  require('./tar')(cli);
 | 
			
		||||
  require('./dev')(cli);
 | 
			
		||||
  require('./start')(cli);
 | 
			
		||||
  require('./e2e')(cli);
 | 
			
		||||
  require('./clean')(cli);
 | 
			
		||||
  require('./doc')(cli);
 | 
			
		||||
  require('./pm2')(cli);
 | 
			
		||||
  require('./test')(cli);
 | 
			
		||||
  require('./umi')(cli);
 | 
			
		||||
  require('./upgrade')(cli);
 | 
			
		||||
  require('./postinstall')(cli);
 | 
			
		||||
  if (isPackageValid('@umijs/utils')) {
 | 
			
		||||
    require('./create-plugin')(cli);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										34
									
								
								packages/core/cli/src/commands/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								packages/core/cli/src/commands/index.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { generateAppDir } from '../util';
 | 
			
		||||
import global from './global';
 | 
			
		||||
import createNginxConf from './create-nginx-conf';
 | 
			
		||||
import build from './build';
 | 
			
		||||
import tar from './tar';
 | 
			
		||||
import dev from './dev';
 | 
			
		||||
import start from './start';
 | 
			
		||||
import e2e from './e2e';
 | 
			
		||||
import clean from './clean';
 | 
			
		||||
import pm2 from './pm2';
 | 
			
		||||
import test from './test';
 | 
			
		||||
import umi from './umi';
 | 
			
		||||
import upgrade from './upgrade';
 | 
			
		||||
import postinstall from './postinstall';
 | 
			
		||||
import createPlugin from './create-plugin';
 | 
			
		||||
 | 
			
		||||
export default async (cli: Command) => {
 | 
			
		||||
  generateAppDir();
 | 
			
		||||
  global(cli);
 | 
			
		||||
  createNginxConf(cli);
 | 
			
		||||
  build(cli);
 | 
			
		||||
  tar(cli);
 | 
			
		||||
  dev(cli);
 | 
			
		||||
  start(cli);
 | 
			
		||||
  e2e(cli);
 | 
			
		||||
  clean(cli);
 | 
			
		||||
  pm2(cli);
 | 
			
		||||
  test(cli);
 | 
			
		||||
  umi(cli);
 | 
			
		||||
  upgrade(cli);
 | 
			
		||||
  postinstall(cli);
 | 
			
		||||
  createPlugin(cli);
 | 
			
		||||
};
 | 
			
		||||
@ -1,28 +1,28 @@
 | 
			
		||||
const execa = require('execa');
 | 
			
		||||
const { resolve } = require('path');
 | 
			
		||||
const pAll = require('p-all');
 | 
			
		||||
const dotenv = require('dotenv');
 | 
			
		||||
const fs = require('fs');
 | 
			
		||||
const glob = require('glob');
 | 
			
		||||
const _ = require('lodash');
 | 
			
		||||
import { execa } from 'execa';
 | 
			
		||||
import { resolve } from 'path';
 | 
			
		||||
import pAll from 'p-all';
 | 
			
		||||
import { parse } from 'dotenv';
 | 
			
		||||
import { existsSync, readFileSync, mkdirSync } from 'fs';
 | 
			
		||||
import fastGlob from 'fast-glob';
 | 
			
		||||
import lodash from 'lodash';
 | 
			
		||||
 | 
			
		||||
let ENV_FILE = resolve(process.cwd(), '.env.e2e');
 | 
			
		||||
 | 
			
		||||
if (!fs.existsSync(ENV_FILE)) {
 | 
			
		||||
if (!existsSync(ENV_FILE)) {
 | 
			
		||||
  ENV_FILE = resolve(process.cwd(), '.env.e2e.example');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const data = fs.readFileSync(ENV_FILE, 'utf-8');
 | 
			
		||||
const data = readFileSync(ENV_FILE, 'utf-8');
 | 
			
		||||
const config = {
 | 
			
		||||
  ...dotenv.parse(data),
 | 
			
		||||
  ...parse(data),
 | 
			
		||||
  ...process.env,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
async function runApp(dir, index = 0) {
 | 
			
		||||
async function runApp(dir: string, index = 0) {
 | 
			
		||||
  // 一个进程需要占用两个端口? (一个是应用端口,一个是 socket 端口)
 | 
			
		||||
  index = index * 2;
 | 
			
		||||
  const { Client } = require('pg');
 | 
			
		||||
  const database = `nocobase${index}`;
 | 
			
		||||
  const database = `tachybase${index}`;
 | 
			
		||||
  const client = new Client({
 | 
			
		||||
    host: config['DB_HOST'],
 | 
			
		||||
    port: Number(config['DB_PORT']),
 | 
			
		||||
@ -34,18 +34,18 @@ async function runApp(dir, index = 0) {
 | 
			
		||||
  await client.query(`DROP DATABASE IF EXISTS "${database}"`);
 | 
			
		||||
  await client.query(`CREATE DATABASE "${database}";`);
 | 
			
		||||
  await client.end();
 | 
			
		||||
  return execa('pnpm', ['nocobase', 'e2e', 'test', dir, '--skip-reporter'], {
 | 
			
		||||
  return execa('pnpm', ['tachybase', 'e2e', 'test', dir, '--skip-reporter'], {
 | 
			
		||||
    shell: true,
 | 
			
		||||
    stdio: 'inherit',
 | 
			
		||||
    env: {
 | 
			
		||||
      ...config,
 | 
			
		||||
      CI: process.env.CI,
 | 
			
		||||
      __E2E__: true,
 | 
			
		||||
      __E2E__: true + '',
 | 
			
		||||
      APP_BASE_URL: undefined,
 | 
			
		||||
      LOGGER_LEVEL: 'error',
 | 
			
		||||
      APP_ENV: 'production',
 | 
			
		||||
      APP_PORT: 20000 + index,
 | 
			
		||||
      DB_DATABASE: `nocobase${index}`,
 | 
			
		||||
      APP_PORT: 20000 + index + '',
 | 
			
		||||
      DB_DATABASE: `tachybase${index}`,
 | 
			
		||||
      SOCKET_PATH: `storage/e2e/gateway-e2e-${index}.sock`,
 | 
			
		||||
      PM2_HOME: resolve(process.cwd(), `storage/e2e/.pm2-${index}`),
 | 
			
		||||
      PLAYWRIGHT_AUTH_FILE: resolve(process.cwd(), `storage/playwright/.auth/admin-${index}.json`),
 | 
			
		||||
@ -53,26 +53,27 @@ async function runApp(dir, index = 0) {
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.pTest = async (options) => {
 | 
			
		||||
export async function pTest(options: any) {
 | 
			
		||||
  const dir = resolve(process.cwd(), 'storage/e2e');
 | 
			
		||||
 | 
			
		||||
  if (!fs.existsSync(dir)) {
 | 
			
		||||
    fs.mkdirSync(dir, { recursive: true });
 | 
			
		||||
  if (!existsSync(dir)) {
 | 
			
		||||
    mkdirSync(dir, { recursive: true });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const files = glob.sync(options.match, {
 | 
			
		||||
  const files = fastGlob.sync(options.match, {
 | 
			
		||||
    ignore: options.ignore,
 | 
			
		||||
    // @ts-ignore
 | 
			
		||||
    root: process.cwd(),
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const commands = splitArrayIntoParts(_.shuffle(files), options.concurrency || 4).map((v, i) => {
 | 
			
		||||
  const commands = splitArrayIntoParts(lodash.shuffle(files), options.concurrency || 4).map((v, i) => {
 | 
			
		||||
    return () => runApp(v.join(' '), i);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  await pAll(commands, { concurrency: 4, stopOnError: false, ...options });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function splitArrayIntoParts(array, parts) {
 | 
			
		||||
  let chunkSize = Math.ceil(array.length / parts);
 | 
			
		||||
  return _.chunk(array, chunkSize);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function splitArrayIntoParts(array: any[], parts: number) {
 | 
			
		||||
  const chunkSize = Math.ceil(array.length / parts);
 | 
			
		||||
  return lodash.chunk(array, chunkSize);
 | 
			
		||||
}
 | 
			
		||||
@ -1,12 +1,7 @@
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { run, isDev } = require('../util');
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { run } from '../util';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  cli
 | 
			
		||||
    .command('pm2')
 | 
			
		||||
    .allowUnknownOption()
 | 
			
		||||
@ -1,14 +1,11 @@
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { run, isDev, isPackageValid, generatePlaywrightPath } = require('../util');
 | 
			
		||||
const { resolve } = require('path');
 | 
			
		||||
const { existsSync } = require('fs');
 | 
			
		||||
const { readFile, writeFile } = require('fs').promises;
 | 
			
		||||
const { createStoragePluginsSymlink, createDevPluginsSymlink } = require('@nocobase/utils/plugin-symlink');
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { run, isDev, isPackageValid, generatePlaywrightPath } from '../util';
 | 
			
		||||
import { resolve } from 'path';
 | 
			
		||||
import { existsSync } from 'fs';
 | 
			
		||||
import { readFile, writeFile } from 'fs/promises';
 | 
			
		||||
import { createStoragePluginsSymlink, createDevPluginsSymlink } from '@nocobase/utils/plugin-symlink';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  const { APP_PACKAGE_ROOT } = process.env;
 | 
			
		||||
  cli
 | 
			
		||||
    .command('postinstall')
 | 
			
		||||
@ -1,15 +1,11 @@
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { isDev, run, postCheck, runInstall, promptForTs } = require('../util');
 | 
			
		||||
const { existsSync, unlink } = require('fs');
 | 
			
		||||
const { resolve } = require('path');
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
const _ = require('lodash');
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { run, postCheck, promptForTs } from '../util';
 | 
			
		||||
import { existsSync } from 'fs';
 | 
			
		||||
import { resolve } from 'path';
 | 
			
		||||
import chalk from 'chalk';
 | 
			
		||||
import _ from 'lodash';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  const { APP_PACKAGE_ROOT, NODE_ARGS } = process.env;
 | 
			
		||||
  cli
 | 
			
		||||
    .command('start')
 | 
			
		||||
@ -27,7 +23,7 @@ module.exports = (cli) => {
 | 
			
		||||
        promptForTs();
 | 
			
		||||
        run('ts-node', [
 | 
			
		||||
          '-P',
 | 
			
		||||
          process.env.SERVER_TSCONFIG_PATH,
 | 
			
		||||
          process.env.SERVER_TSCONFIG_PATH ?? '',
 | 
			
		||||
          '-r',
 | 
			
		||||
          'tsconfig-paths/register',
 | 
			
		||||
          `${APP_PACKAGE_ROOT}/src/index.ts`,
 | 
			
		||||
@ -48,6 +44,7 @@ module.exports = (cli) => {
 | 
			
		||||
      } else {
 | 
			
		||||
        run(
 | 
			
		||||
          'pm2-runtime',
 | 
			
		||||
          // @ts-ignore
 | 
			
		||||
          [
 | 
			
		||||
            'start',
 | 
			
		||||
            '-i',
 | 
			
		||||
@ -1,12 +1,8 @@
 | 
			
		||||
const { resolve } = require('path');
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { run, nodeCheck, isPackageValid } = require('../util');
 | 
			
		||||
import { resolve } from 'path';
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { run, nodeCheck, isPackageValid } from '../util';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  cli
 | 
			
		||||
    .command('tar')
 | 
			
		||||
    .allowUnknownOption()
 | 
			
		||||
@ -1,13 +1,8 @@
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { run } = require('../util');
 | 
			
		||||
const path = require('path');
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { run } from '../util';
 | 
			
		||||
import { sep } from 'path';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {String} name
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
function addTestCommand(name, cli) {
 | 
			
		||||
function addTestCommand(name: string, cli: Command) {
 | 
			
		||||
  return cli
 | 
			
		||||
    .command(name)
 | 
			
		||||
    .option('-w, --watch')
 | 
			
		||||
@ -39,7 +34,7 @@ function addTestCommand(name, cli) {
 | 
			
		||||
      }
 | 
			
		||||
      const first = paths?.[0];
 | 
			
		||||
      if (!process.env.TEST_ENV && first) {
 | 
			
		||||
        const key = first.split(path.sep).join('/');
 | 
			
		||||
        const key = first.split(sep).join('/');
 | 
			
		||||
        if (key.includes('/client/')) {
 | 
			
		||||
          process.env.TEST_ENV = 'client-side';
 | 
			
		||||
        } else {
 | 
			
		||||
@ -77,11 +72,7 @@ function addTestCommand(name, cli) {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  addTestCommand('test:server', cli);
 | 
			
		||||
  addTestCommand('test:client', cli);
 | 
			
		||||
  addTestCommand('test', cli).option('--client').option('--server');
 | 
			
		||||
@ -1,12 +1,7 @@
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { run, isDev } = require('../util');
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { run, isDev } from '../util';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  const { APP_PACKAGE_ROOT } = process.env;
 | 
			
		||||
  cli
 | 
			
		||||
    .command('umi')
 | 
			
		||||
@ -1,15 +1,9 @@
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
const { Command } = require('commander');
 | 
			
		||||
const { resolve } = require('path');
 | 
			
		||||
const { run, promptForTs, runAppCommand, hasCorePackages, updateJsonFile, hasTsNode } = require('../util');
 | 
			
		||||
const { existsSync, rmSync } = require('fs');
 | 
			
		||||
import { Command } from 'commander';
 | 
			
		||||
import { resolve } from 'path';
 | 
			
		||||
import { run, promptForTs, runAppCommand, hasCorePackages, hasTsNode } from '../util';
 | 
			
		||||
import { existsSync, rmSync } from 'fs';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Command} cli
 | 
			
		||||
 */
 | 
			
		||||
module.exports = (cli) => {
 | 
			
		||||
  const { APP_PACKAGE_ROOT } = process.env;
 | 
			
		||||
export default (cli: Command) => {
 | 
			
		||||
  cli
 | 
			
		||||
    .command('upgrade')
 | 
			
		||||
    .allowUnknownOption()
 | 
			
		||||
@ -36,7 +30,7 @@ module.exports = (cli) => {
 | 
			
		||||
      if (existsSync(appDevDir)) {
 | 
			
		||||
        rmSync(appDevDir, { recursive: true, force: true });
 | 
			
		||||
      }
 | 
			
		||||
      await run('pnpm', ['add', '@nocobase/cli', '@nocobase/devtools', '-w']);
 | 
			
		||||
      await run('pnpm', ['add', '@tachybase/cli', '@nocobase/devtools', '-w']);
 | 
			
		||||
      await run('pnpm', ['install']);
 | 
			
		||||
      await runAppCommand('upgrade');
 | 
			
		||||
    });
 | 
			
		||||
@ -1,5 +0,0 @@
 | 
			
		||||
const util = require('./util');
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  ...util,
 | 
			
		||||
};
 | 
			
		||||
@ -1,34 +1,29 @@
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
const { existsSync } = require('fs');
 | 
			
		||||
const { join, resolve } = require('path');
 | 
			
		||||
const { Generator } = require('@umijs/utils');
 | 
			
		||||
const { readFile, writeFile } = require('fs').promises;
 | 
			
		||||
const { genTsConfigPaths } = require('./util');
 | 
			
		||||
import chalk from 'chalk';
 | 
			
		||||
import { existsSync } from 'fs';
 | 
			
		||||
import { join, resolve } from 'path';
 | 
			
		||||
import { Generator } from '@umijs/utils';
 | 
			
		||||
import { readFile } from 'fs/promises';
 | 
			
		||||
import { genTsConfigPaths } from './util';
 | 
			
		||||
import { execa } from 'execa';
 | 
			
		||||
 | 
			
		||||
const execa = require('execa');
 | 
			
		||||
 | 
			
		||||
function camelize(str) {
 | 
			
		||||
function camelize(str: string) {
 | 
			
		||||
  return str.trim().replace(/[-_\s]+(.)?/g, (match, c) => c.toUpperCase());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function capitalize(string) {
 | 
			
		||||
function capitalize(string: string) {
 | 
			
		||||
  return string.charAt(0).toUpperCase() + string.slice(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function getProjectName() {
 | 
			
		||||
  const content = await readFile(resolve(process.cwd(), 'package.json'), 'utf-8');
 | 
			
		||||
  const json = JSON.parse(content);
 | 
			
		||||
  return json.name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function getProjectVersion() {
 | 
			
		||||
  const content = await readFile(resolve(process.cwd(), 'package.json'), 'utf-8');
 | 
			
		||||
  const json = JSON.parse(content);
 | 
			
		||||
  return json.version || '0.1.0';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class PluginGenerator extends Generator {
 | 
			
		||||
  constructor(options) {
 | 
			
		||||
export class PluginGenerator extends Generator {
 | 
			
		||||
  context: any;
 | 
			
		||||
  log: any;
 | 
			
		||||
  constructor(options: any) {
 | 
			
		||||
    const { log, context = {}, ...opts } = options;
 | 
			
		||||
    super(opts);
 | 
			
		||||
    this.context = context;
 | 
			
		||||
@ -63,9 +58,7 @@ class PluginGenerator extends Generator {
 | 
			
		||||
    });
 | 
			
		||||
    this.log('');
 | 
			
		||||
    genTsConfigPaths();
 | 
			
		||||
    execa.sync('pnpm', ['postinstall', '--skip-umi'], { shell: true, stdio: 'inherit' });
 | 
			
		||||
    execa('pnpm', ['postinstall', '--skip-umi'], { shell: true, stdio: 'inherit' });
 | 
			
		||||
    this.log(`The plugin folder is in ${chalk.green(`packages/plugins/${name}`)}`);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.PluginGenerator = PluginGenerator;
 | 
			
		||||
@ -1,39 +1,48 @@
 | 
			
		||||
const net = require('net');
 | 
			
		||||
const chalk = require('chalk');
 | 
			
		||||
const execa = require('execa');
 | 
			
		||||
const fg = require('fast-glob');
 | 
			
		||||
const { dirname, join, resolve, sep } = require('path');
 | 
			
		||||
const { readFile, writeFile } = require('fs').promises;
 | 
			
		||||
const { existsSync, mkdirSync, cpSync, writeFileSync } = require('fs');
 | 
			
		||||
const dotenv = require('dotenv');
 | 
			
		||||
const fs = require('fs');
 | 
			
		||||
import { Socket } from 'net';
 | 
			
		||||
import chalk from 'chalk';
 | 
			
		||||
import { execa, Options } from 'execa';
 | 
			
		||||
import fastGlob from 'fast-glob';
 | 
			
		||||
import { dirname, join, resolve, sep } from 'path';
 | 
			
		||||
import { readFile, writeFile } from 'fs/promises';
 | 
			
		||||
import { existsSync, mkdirSync, cpSync, writeFileSync } from 'fs';
 | 
			
		||||
import { config } from 'dotenv';
 | 
			
		||||
import {
 | 
			
		||||
  unlinkSync,
 | 
			
		||||
  symlinkSync,
 | 
			
		||||
  existsSync as _existsSync,
 | 
			
		||||
  rmSync,
 | 
			
		||||
  cpSync as _cpSync,
 | 
			
		||||
  copyFileSync,
 | 
			
		||||
  readFileSync,
 | 
			
		||||
  writeFileSync as _writeFileSync,
 | 
			
		||||
} from 'fs';
 | 
			
		||||
 | 
			
		||||
exports.isPackageValid = (pkg) => {
 | 
			
		||||
export function isPackageValid(pkg: string) {
 | 
			
		||||
  try {
 | 
			
		||||
    require.resolve(pkg);
 | 
			
		||||
    import.meta.resolve(join(process.cwd(), pkg));
 | 
			
		||||
    return true;
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.hasCorePackages = () => {
 | 
			
		||||
export function hasCorePackages() {
 | 
			
		||||
  const coreDir = resolve(process.cwd(), 'packages/core/build');
 | 
			
		||||
  return existsSync(coreDir);
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.hasTsNode = () => {
 | 
			
		||||
  return exports.isPackageValid('ts-node/dist/bin');
 | 
			
		||||
};
 | 
			
		||||
export function hasTsNode() {
 | 
			
		||||
  return isPackageValid('ts-node/dist/bin');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.isDev = function isDev() {
 | 
			
		||||
export function isDev() {
 | 
			
		||||
  if (process.env.APP_ENV === 'production') {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  return exports.hasTsNode();
 | 
			
		||||
};
 | 
			
		||||
  return hasTsNode();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const isProd = () => {
 | 
			
		||||
export const isProd = () => {
 | 
			
		||||
  const { APP_PACKAGE_ROOT } = process.env;
 | 
			
		||||
  const file = `${APP_PACKAGE_ROOT}/lib/index.js`;
 | 
			
		||||
  if (!existsSync(resolve(process.cwd(), file))) {
 | 
			
		||||
@ -46,17 +55,15 @@ const isProd = () => {
 | 
			
		||||
  return true;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.isProd = isProd;
 | 
			
		||||
 | 
			
		||||
exports.nodeCheck = () => {
 | 
			
		||||
  if (!exports.hasTsNode()) {
 | 
			
		||||
export function nodeCheck() {
 | 
			
		||||
  if (!hasTsNode()) {
 | 
			
		||||
    console.log('Please install all dependencies');
 | 
			
		||||
    console.log(chalk.yellow('$ pnpm install'));
 | 
			
		||||
    process.exit(1);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.run = (command, args, options = {}) => {
 | 
			
		||||
export function run(command: string, args?: string[], options?: Options<any>) {
 | 
			
		||||
  if (command === 'tsx') {
 | 
			
		||||
    command = 'node';
 | 
			
		||||
    args = ['./node_modules/tsx/dist/cli.mjs'].concat(args || []);
 | 
			
		||||
@ -67,14 +74,21 @@ exports.run = (command, args, options = {}) => {
 | 
			
		||||
    ...options,
 | 
			
		||||
    env: {
 | 
			
		||||
      ...process.env,
 | 
			
		||||
      ...options.env,
 | 
			
		||||
      ...(options?.env ?? {}),
 | 
			
		||||
    },
 | 
			
		||||
  });
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.isPortReachable = async (port, { timeout = 1000, host } = {}) => {
 | 
			
		||||
  const promise = new Promise((resolve, reject) => {
 | 
			
		||||
    const socket = new net.Socket();
 | 
			
		||||
interface IPortReachableOptions {
 | 
			
		||||
  timeout: number;
 | 
			
		||||
  host: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function isPortReachable(port: string, options: Partial<IPortReachableOptions> = {}) {
 | 
			
		||||
  const timeout = options.timeout ?? 1000;
 | 
			
		||||
  const host = options.host ?? '';
 | 
			
		||||
  const promise = new Promise<void>((resolve, reject) => {
 | 
			
		||||
    const socket = new Socket();
 | 
			
		||||
 | 
			
		||||
    const onError = () => {
 | 
			
		||||
      socket.destroy();
 | 
			
		||||
@ -85,7 +99,7 @@ exports.isPortReachable = async (port, { timeout = 1000, host } = {}) => {
 | 
			
		||||
    socket.once('error', onError);
 | 
			
		||||
    socket.once('timeout', onError);
 | 
			
		||||
 | 
			
		||||
    socket.connect(port, host, () => {
 | 
			
		||||
    socket.connect(Number(port), host, () => {
 | 
			
		||||
      socket.end();
 | 
			
		||||
      resolve();
 | 
			
		||||
    });
 | 
			
		||||
@ -97,21 +111,25 @@ exports.isPortReachable = async (port, { timeout = 1000, host } = {}) => {
 | 
			
		||||
  } catch (_) {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.postCheck = async (opts) => {
 | 
			
		||||
  const port = opts.port || process.env.APP_PORT;
 | 
			
		||||
  const result = await exports.isPortReachable(port);
 | 
			
		||||
export async function postCheck(opts: { port?: string }) {
 | 
			
		||||
  const port = opts.port || process.env.APP_PORT || '';
 | 
			
		||||
  const result = await isPortReachable(port);
 | 
			
		||||
  if (result) {
 | 
			
		||||
    console.error(chalk.red(`post already in use ${port}`));
 | 
			
		||||
    process.exit(1);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.runInstall = async () => {
 | 
			
		||||
export async function runInstall() {
 | 
			
		||||
  const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env;
 | 
			
		||||
 | 
			
		||||
  if (exports.isDev()) {
 | 
			
		||||
  if (!SERVER_TSCONFIG_PATH) {
 | 
			
		||||
    throw new Error('SERVER_TSCONFIG_PATH is empty.');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (isDev()) {
 | 
			
		||||
    const argv = [
 | 
			
		||||
      '--tsconfig',
 | 
			
		||||
      SERVER_TSCONFIG_PATH,
 | 
			
		||||
@ -121,18 +139,22 @@ exports.runInstall = async () => {
 | 
			
		||||
      'install',
 | 
			
		||||
      '-s',
 | 
			
		||||
    ];
 | 
			
		||||
    await exports.run('tsx', argv);
 | 
			
		||||
    await run('tsx', argv);
 | 
			
		||||
  } else if (isProd()) {
 | 
			
		||||
    const file = `${APP_PACKAGE_ROOT}/lib/index.js`;
 | 
			
		||||
    const argv = [file, 'install', '-s'];
 | 
			
		||||
    await exports.run('node', argv);
 | 
			
		||||
    await run('node', argv);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.runAppCommand = async (command, args = []) => {
 | 
			
		||||
export async function runAppCommand(command: string, args = []) {
 | 
			
		||||
  const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env;
 | 
			
		||||
 | 
			
		||||
  if (exports.isDev()) {
 | 
			
		||||
  if (!SERVER_TSCONFIG_PATH) {
 | 
			
		||||
    throw new Error('SERVER_TSCONFIG_PATH is not set');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (isDev()) {
 | 
			
		||||
    const argv = [
 | 
			
		||||
      '--tsconfig',
 | 
			
		||||
      SERVER_TSCONFIG_PATH,
 | 
			
		||||
@ -142,34 +164,35 @@ exports.runAppCommand = async (command, args = []) => {
 | 
			
		||||
      command,
 | 
			
		||||
      ...args,
 | 
			
		||||
    ];
 | 
			
		||||
    await exports.run('tsx', argv);
 | 
			
		||||
    await run('tsx', argv);
 | 
			
		||||
  } else if (isProd()) {
 | 
			
		||||
    const argv = [`${APP_PACKAGE_ROOT}/lib/index.js`, command, ...args];
 | 
			
		||||
    await exports.run('node', argv);
 | 
			
		||||
    await run('node', argv);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.promptForTs = () => {
 | 
			
		||||
export function promptForTs() {
 | 
			
		||||
  console.log(chalk.green('WAIT: ') + 'TypeScript compiling...');
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.updateJsonFile = async (target, fn) => {
 | 
			
		||||
export async function updateJsonFile(target: string, fn: any) {
 | 
			
		||||
  const content = await readFile(target, 'utf-8');
 | 
			
		||||
  const json = JSON.parse(content);
 | 
			
		||||
  await writeFile(target, JSON.stringify(fn(json), null, 2), 'utf-8');
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.getVersion = async () => {
 | 
			
		||||
export async function getVersion() {
 | 
			
		||||
  const { stdout } = await execa('npm', ['v', '@nocobase/app-server', 'versions']);
 | 
			
		||||
  const versions = new Function(`return (${stdout})`)();
 | 
			
		||||
  return versions[versions.length - 1];
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.generateAppDir = function generateAppDir() {
 | 
			
		||||
  const appPkgPath = dirname(dirname(require.resolve('@nocobase/app/src/index.ts')));
 | 
			
		||||
export function generateAppDir() {
 | 
			
		||||
  const appPkgPath = dirname(dirname(new URL(import.meta.resolve('@nocobase/app/src/index.ts')).pathname));
 | 
			
		||||
  const appDevDir = resolve(process.cwd(), './storage/.app-dev');
 | 
			
		||||
  if (exports.isDev() && !exports.hasCorePackages() && appPkgPath.includes('node_modules')) {
 | 
			
		||||
  if (isDev() && !hasCorePackages() && appPkgPath.includes('node_modules')) {
 | 
			
		||||
    if (!existsSync(appDevDir)) {
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      mkdirSync(appDevDir, { force: true, recursive: true });
 | 
			
		||||
      cpSync(appPkgPath, appDevDir, {
 | 
			
		||||
        recursive: true,
 | 
			
		||||
@ -181,12 +204,12 @@ exports.generateAppDir = function generateAppDir() {
 | 
			
		||||
    process.env.APP_PACKAGE_ROOT = appPkgPath;
 | 
			
		||||
  }
 | 
			
		||||
  buildIndexHtml();
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.genTsConfigPaths = function genTsConfigPaths() {
 | 
			
		||||
export async function genTsConfigPaths() {
 | 
			
		||||
  try {
 | 
			
		||||
    fs.unlinkSync(resolve(process.cwd(), 'node_modules/.bin/tsx'));
 | 
			
		||||
    fs.symlinkSync(
 | 
			
		||||
    unlinkSync(resolve(process.cwd(), 'node_modules/.bin/tsx'));
 | 
			
		||||
    symlinkSync(
 | 
			
		||||
      resolve(process.cwd(), 'node_modules/tsx/dist/cli.mjs'),
 | 
			
		||||
      resolve(process.cwd(), 'node_modules/.bin/tsx'),
 | 
			
		||||
      'file',
 | 
			
		||||
@ -197,56 +220,57 @@ exports.genTsConfigPaths = function genTsConfigPaths() {
 | 
			
		||||
 | 
			
		||||
  const cwd = process.cwd();
 | 
			
		||||
  const cwdLength = cwd.length;
 | 
			
		||||
  const paths = {
 | 
			
		||||
  const paths: Record<string, string[]> = {
 | 
			
		||||
    '@@/*': ['.dumi/tmp/*'],
 | 
			
		||||
  };
 | 
			
		||||
  const packages = fg.sync(['packages/*/*/package.json', 'packages/*/*/*/package.json'], {
 | 
			
		||||
  const packages = fastGlob.sync(['packages/*/*/package.json', 'packages/*/*/*/package.json'], {
 | 
			
		||||
    absolute: true,
 | 
			
		||||
    onlyFiles: true,
 | 
			
		||||
  });
 | 
			
		||||
  packages.forEach((packageFile) => {
 | 
			
		||||
    const packageJsonName = require(packageFile).name;
 | 
			
		||||
    const packageDir = dirname(packageFile);
 | 
			
		||||
    const relativePath = packageDir
 | 
			
		||||
      .slice(cwdLength + 1)
 | 
			
		||||
      .split(sep)
 | 
			
		||||
      .join('/');
 | 
			
		||||
    paths[`${packageJsonName}/client`] = [`${relativePath}/src/client`];
 | 
			
		||||
    paths[`${packageJsonName}/package.json`] = [`${relativePath}/package.json`];
 | 
			
		||||
    paths[packageJsonName] = [`${relativePath}/src`];
 | 
			
		||||
    if (packageJsonName === '@nocobase/test') {
 | 
			
		||||
      paths[`${packageJsonName}/server`] = [`${relativePath}/src/server`];
 | 
			
		||||
      paths[`${packageJsonName}/e2e`] = [`${relativePath}/src/e2e`];
 | 
			
		||||
    }
 | 
			
		||||
    if (packageJsonName === '@nocobase/plugin-workflow-test') {
 | 
			
		||||
      paths[`${packageJsonName}/e2e`] = [`${relativePath}/src/e2e`];
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  await Promise.all(
 | 
			
		||||
    packages.map(async (packageFile) => {
 | 
			
		||||
      const packageJsonName = (await import(packageFile, { assert: { type: 'json' } })).name;
 | 
			
		||||
      const packageDir = dirname(packageFile);
 | 
			
		||||
      const relativePath = packageDir
 | 
			
		||||
        .slice(cwdLength + 1)
 | 
			
		||||
        .split(sep)
 | 
			
		||||
        .join('/');
 | 
			
		||||
      paths[`${packageJsonName}/client`] = [`${relativePath}/src/client`];
 | 
			
		||||
      paths[`${packageJsonName}/package.json`] = [`${relativePath}/package.json`];
 | 
			
		||||
      paths[packageJsonName] = [`${relativePath}/src`];
 | 
			
		||||
      if (packageJsonName === '@nocobase/test') {
 | 
			
		||||
        paths[`${packageJsonName}/server`] = [`${relativePath}/src/server`];
 | 
			
		||||
        paths[`${packageJsonName}/e2e`] = [`${relativePath}/src/e2e`];
 | 
			
		||||
      }
 | 
			
		||||
      if (packageJsonName === '@nocobase/plugin-workflow-test') {
 | 
			
		||||
        paths[`${packageJsonName}/e2e`] = [`${relativePath}/src/e2e`];
 | 
			
		||||
      }
 | 
			
		||||
    }),
 | 
			
		||||
  );
 | 
			
		||||
  const tsConfigJsonPath = join(cwd, './tsconfig.paths.json');
 | 
			
		||||
  const content = { compilerOptions: { paths } };
 | 
			
		||||
  writeFileSync(tsConfigJsonPath, JSON.stringify(content, null, 2), 'utf-8');
 | 
			
		||||
  return content;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function generatePlaywrightPath(clean = false) {
 | 
			
		||||
  return content;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function generatePlaywrightPath(clean = false) {
 | 
			
		||||
  try {
 | 
			
		||||
    const playwright = resolve(process.cwd(), 'storage/playwright/tests');
 | 
			
		||||
    if (clean && fs.existsSync(playwright)) {
 | 
			
		||||
      fs.rmSync(dirname(playwright), { force: true, recursive: true });
 | 
			
		||||
    if (clean && _existsSync(playwright)) {
 | 
			
		||||
      rmSync(dirname(playwright), { force: true, recursive: true });
 | 
			
		||||
    }
 | 
			
		||||
    if (!fs.existsSync(playwright)) {
 | 
			
		||||
    if (!_existsSync(playwright)) {
 | 
			
		||||
      const testPkg = require.resolve('@nocobase/test/package.json');
 | 
			
		||||
      fs.cpSync(resolve(dirname(testPkg), 'playwright/tests'), playwright, { recursive: true });
 | 
			
		||||
      _cpSync(resolve(dirname(testPkg), 'playwright/tests'), playwright, { recursive: true });
 | 
			
		||||
    }
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    // empty
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.generatePlaywrightPath = generatePlaywrightPath;
 | 
			
		||||
 | 
			
		||||
function parseEnv(name) {
 | 
			
		||||
function parseEnv(name: string) {
 | 
			
		||||
  if (name === 'DB_UNDERSCORED') {
 | 
			
		||||
    if (process.env.DB_UNDERSCORED === 'true') {
 | 
			
		||||
      return 'true';
 | 
			
		||||
@ -258,31 +282,29 @@ function parseEnv(name) {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function buildIndexHtml(force = false) {
 | 
			
		||||
export function buildIndexHtml(force = false) {
 | 
			
		||||
  const file = `${process.env.APP_PACKAGE_ROOT}/dist/client/index.html`;
 | 
			
		||||
  if (!fs.existsSync(file)) {
 | 
			
		||||
  if (!_existsSync(file)) {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  const tpl = `${process.env.APP_PACKAGE_ROOT}/dist/client/index.html.tpl`;
 | 
			
		||||
  if (force && fs.existsSync(tpl)) {
 | 
			
		||||
    fs.rmSync(tpl);
 | 
			
		||||
  if (force && _existsSync(tpl)) {
 | 
			
		||||
    rmSync(tpl);
 | 
			
		||||
  }
 | 
			
		||||
  if (!fs.existsSync(tpl)) {
 | 
			
		||||
    fs.copyFileSync(file, tpl);
 | 
			
		||||
  if (!_existsSync(tpl)) {
 | 
			
		||||
    copyFileSync(file, tpl);
 | 
			
		||||
  }
 | 
			
		||||
  const data = fs.readFileSync(tpl, 'utf-8');
 | 
			
		||||
  const data = readFileSync(tpl, 'utf-8');
 | 
			
		||||
  const replacedData = data
 | 
			
		||||
    .replace(/\{\{env.APP_PUBLIC_PATH\}\}/g, process.env.APP_PUBLIC_PATH)
 | 
			
		||||
    .replace(/\{\{env.API_BASE_URL\}\}/g, process.env.API_BASE_URL || process.env.API_BASE_PATH)
 | 
			
		||||
    .replace(/\{\{env.WS_URL\}\}/g, process.env.WEBSOCKET_URL || '')
 | 
			
		||||
    .replace(/\{\{env.WS_PATH\}\}/g, process.env.WS_PATH)
 | 
			
		||||
    .replace(/\{\{env.APP_PUBLIC_PATH\}\}/g, process.env.APP_PUBLIC_PATH ?? '')
 | 
			
		||||
    .replace(/\{\{env.API_BASE_URL\}\}/g, process.env.API_BASE_URL ?? process.env.API_BASE_PATH ?? '')
 | 
			
		||||
    .replace(/\{\{env.WS_URL\}\}/g, process.env.WEBSOCKET_URL ?? '')
 | 
			
		||||
    .replace(/\{\{env.WS_PATH\}\}/g, process.env.WS_PATH ?? '')
 | 
			
		||||
    .replace('src="/umi.', `src="${process.env.APP_PUBLIC_PATH}umi.`);
 | 
			
		||||
  fs.writeFileSync(file, replacedData, 'utf-8');
 | 
			
		||||
  _writeFileSync(file, replacedData, 'utf-8');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.buildIndexHtml = buildIndexHtml;
 | 
			
		||||
 | 
			
		||||
exports.initEnv = function initEnv() {
 | 
			
		||||
export function initEnv() {
 | 
			
		||||
  const env = {
 | 
			
		||||
    APP_ENV: 'development',
 | 
			
		||||
    APP_KEY: 'test-jwt-secret',
 | 
			
		||||
@ -316,7 +338,7 @@ exports.initEnv = function initEnv() {
 | 
			
		||||
    process.argv[2] &&
 | 
			
		||||
    ['test', 'test:client', 'test:server'].includes(process.argv[2])
 | 
			
		||||
  ) {
 | 
			
		||||
    if (fs.existsSync(resolve(process.cwd(), '.env.test'))) {
 | 
			
		||||
    if (_existsSync(resolve(process.cwd(), '.env.test'))) {
 | 
			
		||||
      process.env.APP_ENV_PATH = '.env.test';
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@ -324,17 +346,17 @@ exports.initEnv = function initEnv() {
 | 
			
		||||
  if (!process.env.APP_ENV_PATH && process.argv[2] === 'e2e') {
 | 
			
		||||
    // 用于存放 playwright 自动生成的相关的文件
 | 
			
		||||
    generatePlaywrightPath();
 | 
			
		||||
    if (!fs.existsSync('.env.e2e') && fs.existsSync('.env.e2e.example')) {
 | 
			
		||||
      const env = fs.readFileSync('.env.e2e.example');
 | 
			
		||||
      fs.writeFileSync('.env.e2e', env);
 | 
			
		||||
    if (!_existsSync('.env.e2e') && _existsSync('.env.e2e.example')) {
 | 
			
		||||
      const env = readFileSync('.env.e2e.example');
 | 
			
		||||
      _writeFileSync('.env.e2e', env);
 | 
			
		||||
    }
 | 
			
		||||
    if (!fs.existsSync('.env.e2e')) {
 | 
			
		||||
    if (!_existsSync('.env.e2e')) {
 | 
			
		||||
      throw new Error('Please create .env.e2e file first!');
 | 
			
		||||
    }
 | 
			
		||||
    process.env.APP_ENV_PATH = '.env.e2e';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  dotenv.config({
 | 
			
		||||
  config({
 | 
			
		||||
    path: resolve(process.cwd(), process.env.APP_ENV_PATH || '.env'),
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
@ -344,6 +366,7 @@ exports.initEnv = function initEnv() {
 | 
			
		||||
 | 
			
		||||
  for (const key in env) {
 | 
			
		||||
    if (!process.env[key]) {
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      process.env[key] = env[key];
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@ -354,11 +377,13 @@ exports.initEnv = function initEnv() {
 | 
			
		||||
    for (const key of keys) {
 | 
			
		||||
      process.env[key] = publicPath + process.env[key];
 | 
			
		||||
    }
 | 
			
		||||
    // @ts-ignore
 | 
			
		||||
    process.env.__env_modified__ = true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!process.env.__env_modified__ && process.env.APP_SERVER_BASE_URL && !process.env.API_BASE_URL) {
 | 
			
		||||
    process.env.API_BASE_URL = process.env.APP_SERVER_BASE_URL + process.env.API_BASE_PATH;
 | 
			
		||||
    // @ts-ignore
 | 
			
		||||
    process.env.__env_modified__ = true;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								packages/core/cli/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								packages/core/cli/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
			
		||||
{
 | 
			
		||||
  "compilerOptions": {
 | 
			
		||||
    "baseUrl": ".",
 | 
			
		||||
    "target": "ESNext",
 | 
			
		||||
    "lib": ["esnext"],
 | 
			
		||||
    "module": "ESNext",
 | 
			
		||||
    "moduleResolution": "Bundler",
 | 
			
		||||
    "strict": true,
 | 
			
		||||
    "declaration": true,
 | 
			
		||||
    "noEmit": true,
 | 
			
		||||
    "esModuleInterop": true,
 | 
			
		||||
    "skipLibCheck": true
 | 
			
		||||
  },
 | 
			
		||||
  "include": ["./src/**/*.ts"],
 | 
			
		||||
  "exclude": ["./dist"]
 | 
			
		||||
}
 | 
			
		||||
@ -25,7 +25,7 @@
 | 
			
		||||
    "pm2": "^5.2.0",
 | 
			
		||||
    "@nocobase/preset-nocobase": "{{{version}}}",
 | 
			
		||||
    "@nocobase/build": "{{{version}}}",
 | 
			
		||||
    "@nocobase/cli": "{{{version}}}",
 | 
			
		||||
    "@tachycode/cli": "{{{version}}}",
 | 
			
		||||
    {{{dependencies}}}
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
import { initEnv } from '@nocobase/cli';
 | 
			
		||||
import { initEnv } from '@tachybase/cli';
 | 
			
		||||
 | 
			
		||||
process.env.APP_ENV_PATH = process.env.APP_ENV_PATH || '.env.test';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3338
									
								
								pnpm-lock.yaml
									
									
									
									
									
								
							
							
						
						
									
										3338
									
								
								pnpm-lock.yaml
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user