@nocobase/build 1.0.0-alpha.1 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/build.js CHANGED
@@ -44,6 +44,7 @@ var import_utils = require("./utils");
44
44
  var import_getPackages = require("./utils/getPackages");
45
45
  var import_tarPlugin = require("./tarPlugin");
46
46
  var import_buildEsm = require("./buildEsm");
47
+ var import_addlicense = require("./utils/addlicense");
47
48
  const BUILD_ERROR = "build-error";
48
49
  async function build(pkgs) {
49
50
  const isDev = process.argv.includes("--development");
@@ -71,7 +72,8 @@ async function build(pkgs) {
71
72
  if (clientCore) {
72
73
  await buildPackage(clientCore, "es", import_buildClient.buildClient);
73
74
  }
74
- const esmPackages = cjsPackages.filter((pkg) => import_constant.ESM_PACKAGES.includes(pkg.name));
75
+ const esmPackages = packages.filter((pkg) => import_constant.ESM_PACKAGES.includes(pkg.name));
76
+ await buildPackages(esmPackages, "lib", import_buildCjs.buildCjs);
75
77
  await buildPackages(esmPackages, "es", import_buildEsm.buildEsm);
76
78
  await buildPackages(pluginPackages, "dist", import_buildPlugin.buildPlugin);
77
79
  await buildPackages(presetsPackages, "lib", import_buildCjs.buildCjs);
@@ -124,6 +126,7 @@ async function buildPackage(pkg, targetDir, doBuildPackage) {
124
126
  log("afterBuild");
125
127
  await userConfig.afterBuild(log);
126
128
  }
129
+ await (0, import_addlicense.addLicense)(import_path.default.join(pkg.location, targetDir), log);
127
130
  if (hasTar) {
128
131
  await (0, import_tarPlugin.tarPlugin)(pkg.location, log);
129
132
  }
package/lib/constant.js CHANGED
@@ -85,7 +85,7 @@ const CJS_EXCLUDE_PACKAGES = [
85
85
  import_path.default.join(PACKAGES_PATH, "core/cli"),
86
86
  CORE_CLIENT
87
87
  ];
88
- const getCjsPackages = (packages) => packages.filter((item) => !PLUGINS_DIR.some((dir) => item.location.startsWith(dir))).filter((item) => !item.location.startsWith(PRESETS_DIR)).filter((item) => !CJS_EXCLUDE_PACKAGES.includes(item.location));
88
+ const getCjsPackages = (packages) => packages.filter((item) => !PLUGINS_DIR.some((dir) => item.location.startsWith(dir))).filter((item) => !item.location.startsWith(PRESETS_DIR)).filter((item) => !ESM_PACKAGES.includes(item.name)).filter((item) => !CJS_EXCLUDE_PACKAGES.includes(item.location));
89
89
  const tarIncludesFiles = ["package.json", "README.md", "LICENSE", "dist", "!node_modules"];
90
90
  const TAR_OUTPUT_DIR = process.env.TAR_PATH ? process.env.TAR_PATH : import_path.default.join(ROOT_PATH, "storage", "tar");
91
91
  // Annotate the CommonJS export names for ESM import in node:
package/lib/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
1
10
 
2
11
  import { Options as TsupConfig } from 'tsup'
3
12
  import { InlineConfig as ViteConfig } from 'vite'
@@ -0,0 +1,73 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var addlicense_exports = {};
29
+ __export(addlicense_exports, {
30
+ addLicense: () => addLicense
31
+ });
32
+ module.exports = __toCommonJS(addlicense_exports);
33
+ var import_fast_glob = __toESM(require("fast-glob"));
34
+ var import_fs_extra = __toESM(require("fs-extra"));
35
+ const commercialLicense = `
36
+ /**
37
+ * This file is part of the NocoBase (R) project.
38
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
39
+ * Authors: NocoBase Team.
40
+ *
41
+ * This program is offered under a commercial license.
42
+ * For more information, see <https://www.nocobase.com/agreement>
43
+ */
44
+ `.trim();
45
+ const openSourceLicense = `
46
+ /**
47
+ * This file is part of the NocoBase (R) project.
48
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
49
+ * Authors: NocoBase Team.
50
+ *
51
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
52
+ * For more information, please refer to: https://www.nocobase.com/agreement.
53
+ */
54
+ `.trim();
55
+ function getLicenseText(packageDir) {
56
+ return packageDir.includes("/pro-plugins") ? commercialLicense : openSourceLicense;
57
+ }
58
+ function addLicenseToFile(filePath, licenseText) {
59
+ const data = import_fs_extra.default.readFileSync(filePath, "utf8");
60
+ const newData = licenseText + "\n\n" + data;
61
+ import_fs_extra.default.writeFileSync(filePath, newData, "utf8");
62
+ }
63
+ async function addLicense(cwd, log) {
64
+ const stream = import_fast_glob.default.globStream("**/*.{js,jsx,ts,tsx}", { cwd, ignore: ["node_modules", "**/*.d.ts"], absolute: true, onlyFiles: true });
65
+ const licenseText = getLicenseText(cwd);
66
+ for await (const filePath of stream) {
67
+ addLicenseToFile(filePath, licenseText);
68
+ }
69
+ }
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ addLicense
73
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/build",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "Library build tool based on rollup.",
5
5
  "main": "lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -36,5 +36,5 @@
36
36
  "scripts": {
37
37
  "build": "tsup"
38
38
  },
39
- "gitHead": "c73b6d2032a6151fdfeebeb0ec923d766578c53c"
39
+ "gitHead": "7ccb137c7616cba5d238f87368239640e1d9ace1"
40
40
  }