jiek 2.2.7 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/bin/build.cjs +2 -0
  2. package/bin/index.cjs +2 -0
  3. package/bin-helper/index.cjs +19 -31
  4. package/dist/.internal/.chunks/filterSupport.4rM7f6jB.cjs +114 -0
  5. package/dist/.internal/.chunks/filterSupport.BXWpLBpT.js +104 -0
  6. package/dist/{cli.js → .internal/.chunks/index.B6RQz1DZ.js} +1 -737
  7. package/dist/.internal/.chunks/index.BHuJRlvZ.js +9059 -0
  8. package/dist/.internal/.chunks/index.Daihq2aI.cjs +9071 -0
  9. package/dist/{cli.cjs → .internal/.chunks/index.DlHFuTjM.cjs} +1 -759
  10. package/dist/.internal/.chunks/loadConfig.CFfzkm_p.js +110 -0
  11. package/dist/.internal/.chunks/loadConfig.OOKddvHF.cjs +117 -0
  12. package/dist/{cli-only-build.cjs → .internal/bin/common.cjs} +229 -445
  13. package/dist/.internal/bin/common.d.cts +22 -0
  14. package/dist/.internal/bin/common.d.ts +22 -0
  15. package/dist/{cli-only-build.js → .internal/bin/common.js} +224 -439
  16. package/dist/.internal/bin/parseArgv.cjs +33 -0
  17. package/dist/.internal/bin/parseArgv.d.cts +5 -0
  18. package/dist/.internal/bin/parseArgv.d.ts +5 -0
  19. package/dist/.internal/bin/parseArgv.js +27 -0
  20. package/dist/.internal/bridge.cjs +30 -0
  21. package/dist/.internal/bridge.d.cts +39 -0
  22. package/dist/.internal/bridge.d.ts +39 -0
  23. package/dist/.internal/bridge.js +27 -0
  24. package/dist/.internal/rollup/base.cjs +10 -0
  25. package/dist/{cli-only-build.d.cts → .internal/rollup/base.d.cts} +8 -15
  26. package/dist/{cli-only-build.d.ts → .internal/rollup/base.d.ts} +8 -15
  27. package/dist/.internal/rollup/base.js +7 -0
  28. package/dist/.internal/rollup/bundle-analyzer.cjs +51 -0
  29. package/dist/.internal/rollup/bundle-analyzer.d.cts +92 -0
  30. package/dist/.internal/rollup/bundle-analyzer.d.ts +92 -0
  31. package/dist/.internal/rollup/bundle-analyzer.js +45 -0
  32. package/dist/.internal/utils/filterSupport.cjs +18 -0
  33. package/dist/.internal/utils/filterSupport.d.cts +15 -0
  34. package/dist/.internal/utils/filterSupport.d.ts +15 -0
  35. package/dist/.internal/utils/filterSupport.js +8 -0
  36. package/dist/.internal/utils/getInternalModuleName.cjs +5 -0
  37. package/dist/.internal/utils/getInternalModuleName.d.cts +3 -0
  38. package/dist/.internal/utils/getInternalModuleName.d.ts +3 -0
  39. package/dist/.internal/utils/getInternalModuleName.js +3 -0
  40. package/dist/.internal/utils/intersection.cjs +5 -0
  41. package/dist/.internal/utils/intersection.d.cts +3 -0
  42. package/dist/.internal/utils/intersection.d.ts +3 -0
  43. package/dist/.internal/utils/intersection.js +3 -0
  44. package/dist/.internal/utils/loadConfig.cjs +14 -0
  45. package/dist/.internal/utils/loadConfig.d.cts +10 -0
  46. package/dist/.internal/utils/loadConfig.d.ts +10 -0
  47. package/dist/.internal/utils/loadConfig.js +9 -0
  48. package/dist/.internal/utils/recursiveListFiles.cjs +19 -0
  49. package/dist/.internal/utils/recursiveListFiles.d.cts +3 -0
  50. package/dist/.internal/utils/recursiveListFiles.d.ts +3 -0
  51. package/dist/.internal/utils/recursiveListFiles.js +13 -0
  52. package/dist/.internal/utils/resolveExports.cjs +124 -0
  53. package/dist/.internal/utils/resolveExports.d.cts +27 -0
  54. package/dist/.internal/utils/resolveExports.d.ts +27 -0
  55. package/dist/.internal/utils/resolveExports.js +117 -0
  56. package/dist/.internal/utils/ts.cjs +68 -0
  57. package/dist/.internal/utils/ts.d.cts +3 -0
  58. package/dist/.internal/utils/ts.d.ts +3 -0
  59. package/dist/.internal/utils/ts.js +62 -0
  60. package/dist/bin/build.cjs +10 -0
  61. package/dist/bin/index.cjs +522 -0
  62. package/dist/index.d.cts +16 -114
  63. package/dist/index.d.ts +16 -114
  64. package/dist/rollup/index.cjs +310 -4573
  65. package/dist/rollup/index.d.cts +7 -1
  66. package/dist/rollup/index.d.ts +7 -1
  67. package/dist/rollup/index.js +298 -4558
  68. package/package.json +16 -24
  69. package/src/bin/build.cts +5 -0
  70. package/src/bin/common.ts +3 -0
  71. package/src/bin/index.cts +7 -0
  72. package/src/bridge.ts +1 -1
  73. package/src/commands/base.ts +3 -3
  74. package/src/commands/build/analyzer.ts +5 -5
  75. package/src/commands/build/client/analyzer.tsx +1 -1
  76. package/src/commands/build/client/index.ts +5 -7
  77. package/src/commands/build.ts +244 -213
  78. package/src/commands/meta.ts +1 -1
  79. package/src/commands/publish.ts +190 -78
  80. package/src/index.ts +6 -1
  81. package/src/rollup/base.ts +2 -2
  82. package/src/rollup/index.ts +361 -124
  83. package/src/rollup/plugins/with-external.ts +23 -0
  84. package/src/rollup/utils/externalResolver.ts +20 -8
  85. package/src/utils/checkDependency.ts +1 -1
  86. package/src/utils/filterSupport.ts +17 -16
  87. package/src/utils/getInternalModuleName.ts +5 -0
  88. package/src/utils/intersection.ts +1 -0
  89. package/src/utils/{recusiveListFiles.ts → recursiveListFiles.ts} +2 -2
  90. package/src/utils/{getExports.ts → resolveExports.ts} +28 -19
  91. package/bin/jiek-build.js +0 -16
  92. package/bin/jiek.js +0 -13
  93. package/cli/package.json +0 -1
  94. package/cli-only-build/package.json +0 -1
  95. package/dist/cli.d.cts +0 -14
  96. package/dist/cli.d.ts +0 -14
  97. package/src/cli-only-build.ts +0 -11
  98. package/src/cli.ts +0 -6
  99. /package/{src/bin/build.ts → .jiek-production-tag} +0 -0
  100. /package/src/{parseArgv.ts → bin/parseArgv.ts} +0 -0
package/bin/build.cjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('jiek/bin-helper')
package/bin/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('jiek/bin-helper')
@@ -1,43 +1,31 @@
1
+ const fs = require('node:fs')
2
+ const {
3
+ basename,
4
+ dirname,
5
+ resolve
6
+ } = require('node:path')
1
7
  const process = require('node:process')
2
8
 
3
9
  /**
4
10
  * @type {string | undefined}
5
11
  */
6
- let binFilePath
7
-
8
- try {
9
- // eslint-disable-next-line unicorn/error-message
10
- throw new Error()
11
- } catch (e) {
12
- const { stack } = e
13
- const lines = stack.split('\n')
14
- for (const line of lines) {
15
- if (
16
- line === 'Error' || line.includes(' (node:') || line.includes(` (${__filename}`)
17
- ) {
18
- continue
19
- }
20
- const match = line.match(/\(([^)]+)\)$/)
21
- if (match) {
22
- binFilePath = match[1].replace(/:\d+:\d+$/, '')
23
- }
24
- break
25
- }
26
- }
27
-
28
- binFilePath = binFilePath ?? process.env.JIEK_BIN__FILEPATH
29
-
30
- const {
31
- basename,
32
- dirname
33
- } = require('node:path')
12
+ const binFilePath = module.parent.filename ?? require.main.filename
34
13
 
35
14
  const packageDir = dirname(dirname(binFilePath))
36
- const binFilename = basename(binFilePath).replace(/(\.[cm]?)js$/, '$1ts')
15
+ const binFilename = basename(binFilePath)
37
16
 
38
17
  process.env.JIEK_PACKAGE_DIR = packageDir
39
18
  process.env.JIEK_BIN__FILENAME = binFilename
40
19
  process.env.JIEK_BIN__FILEPATH = binFilePath
41
20
 
42
- require('esbuild-register')
43
- require(`${packageDir}/src/bin/${binFilename}`)
21
+ const resolveByPKG = (...paths) => resolve(packageDir, ...paths)
22
+ const isProduction = fs.existsSync(resolveByPKG(`./.jiek-production-tag`))
23
+
24
+ if (!isProduction) {
25
+ require('esbuild-register')
26
+ }
27
+
28
+ const binPath = isProduction
29
+ ? resolveByPKG(`./dist/bin/${binFilename}`)
30
+ : resolveByPKG(`./src/bin/${binFilename.replace(/(\.[cm]?)js$/, '$1ts')}`)
31
+ require(binPath)
@@ -0,0 +1,114 @@
1
+ 'use strict';
2
+
3
+ var fs = require('node:fs');
4
+ var path = require('node:path');
5
+ var process$1 = require('node:process');
6
+ var commander = require('commander');
7
+ var jsYaml = require('js-yaml');
8
+ var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
13
+ var path__default = /*#__PURE__*/_interopDefault(path);
14
+ var process__default = /*#__PURE__*/_interopDefault(process$1);
15
+
16
+ var require$1 = require;
17
+
18
+ let root;
19
+ function getRoot() {
20
+ if (root) return root;
21
+ const rootOption = process.env.JIEK_ROOT;
22
+ root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : void 0;
23
+ return root;
24
+ }
25
+
26
+ let wd;
27
+ let notWorkspace = false;
28
+ function getWD() {
29
+ if (wd) return { wd, notWorkspace };
30
+ const root = getRoot();
31
+ if (root !== void 0) {
32
+ const isWorkspace = getWorkspaceDir.isWorkspaceDir(root, exports.type);
33
+ notWorkspace = !isWorkspace;
34
+ wd = root;
35
+ return { wd, notWorkspace };
36
+ }
37
+ try {
38
+ wd = getWorkspaceDir.getWorkspaceDir(exports.type);
39
+ } catch (e) {
40
+ if ("message" in e && e.message === "workspace root not found") {
41
+ wd = root ?? process.cwd();
42
+ notWorkspace = true;
43
+ } else {
44
+ throw e;
45
+ }
46
+ }
47
+ return { wd, notWorkspace };
48
+ }
49
+
50
+ exports.type = "";
51
+ try {
52
+ require$1.resolve("@pnpm/filter-workspace-packages");
53
+ exports.type = "pnpm";
54
+ } catch {
55
+ }
56
+ async function filterPackagesGraph(filters) {
57
+ return Promise.all(filters.map(async (filter) => getSelectedProjectsGraph(filter)));
58
+ }
59
+ async function getSelectedProjectsGraph(filter = commander.program.getOptionValue("filter")) {
60
+ const { wd, notWorkspace } = getWD();
61
+ let root = getRoot();
62
+ if (notWorkspace) {
63
+ return {
64
+ root,
65
+ value: {
66
+ [wd]: JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(wd, "package.json"), "utf-8"))
67
+ }
68
+ };
69
+ }
70
+ if (exports.type === "pnpm") {
71
+ const pnpmWorkspaceFilePath = path__default.default.resolve(wd, "pnpm-workspace.yaml");
72
+ const pnpmWorkspaceFileContent = fs__default.default.readFileSync(pnpmWorkspaceFilePath, "utf-8");
73
+ const pnpmWorkspace = jsYaml.load(pnpmWorkspaceFileContent);
74
+ if (root === wd && filter == null) {
75
+ throw new Error("root path is workspace root, please provide a filter");
76
+ }
77
+ if (root === void 0) {
78
+ root = process__default.default.cwd();
79
+ }
80
+ if (root !== wd && filter == null) {
81
+ const packageJSONIsExist = fs__default.default.existsSync(path__default.default.resolve(root, "package.json"));
82
+ if (!packageJSONIsExist) {
83
+ throw new Error("root path is not workspace root, please provide a filter");
84
+ }
85
+ const packageJSON = JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(root, "package.json"), "utf-8"));
86
+ if (packageJSON.name == null) {
87
+ throw new Error("root path is not workspace root, please provide a filter");
88
+ }
89
+ filter = packageJSON.name;
90
+ }
91
+ const { filterPackagesFromDir } = await import('@pnpm/filter-workspace-packages');
92
+ const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
93
+ filter: filter ?? "",
94
+ followProdDepsOnly: true
95
+ }], {
96
+ prefix: root,
97
+ workspaceDir: wd,
98
+ patterns: pnpmWorkspace.packages
99
+ });
100
+ return {
101
+ root,
102
+ value: Object.entries(selectedProjectsGraph).reduce((acc, [key, value]) => {
103
+ acc[key] = value.package.manifest;
104
+ return acc;
105
+ }, {})
106
+ };
107
+ }
108
+ throw new Error(`not supported package manager ${exports.type}`);
109
+ }
110
+
111
+ exports.filterPackagesGraph = filterPackagesGraph;
112
+ exports.getSelectedProjectsGraph = getSelectedProjectsGraph;
113
+ exports.getWD = getWD;
114
+ exports.require = require$1;
@@ -0,0 +1,104 @@
1
+ import { createRequire } from 'node:module';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import process$1 from 'node:process';
5
+ import { program } from 'commander';
6
+ import { load } from 'js-yaml';
7
+ import { isWorkspaceDir, getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
8
+
9
+ var require = /* @__PURE__ */ createRequire(import.meta.url);
10
+
11
+ let root;
12
+ function getRoot() {
13
+ if (root) return root;
14
+ const rootOption = process.env.JIEK_ROOT;
15
+ root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : void 0;
16
+ return root;
17
+ }
18
+
19
+ let wd;
20
+ let notWorkspace = false;
21
+ function getWD() {
22
+ if (wd) return { wd, notWorkspace };
23
+ const root = getRoot();
24
+ if (root !== void 0) {
25
+ const isWorkspace = isWorkspaceDir(root, type);
26
+ notWorkspace = !isWorkspace;
27
+ wd = root;
28
+ return { wd, notWorkspace };
29
+ }
30
+ try {
31
+ wd = getWorkspaceDir(type);
32
+ } catch (e) {
33
+ if ("message" in e && e.message === "workspace root not found") {
34
+ wd = root ?? process.cwd();
35
+ notWorkspace = true;
36
+ } else {
37
+ throw e;
38
+ }
39
+ }
40
+ return { wd, notWorkspace };
41
+ }
42
+
43
+ let type = "";
44
+ try {
45
+ require.resolve("@pnpm/filter-workspace-packages");
46
+ type = "pnpm";
47
+ } catch {
48
+ }
49
+ async function filterPackagesGraph(filters) {
50
+ return Promise.all(filters.map(async (filter) => getSelectedProjectsGraph(filter)));
51
+ }
52
+ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter")) {
53
+ const { wd, notWorkspace } = getWD();
54
+ let root = getRoot();
55
+ if (notWorkspace) {
56
+ return {
57
+ root,
58
+ value: {
59
+ [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, "package.json"), "utf-8"))
60
+ }
61
+ };
62
+ }
63
+ if (type === "pnpm") {
64
+ const pnpmWorkspaceFilePath = path.resolve(wd, "pnpm-workspace.yaml");
65
+ const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, "utf-8");
66
+ const pnpmWorkspace = load(pnpmWorkspaceFileContent);
67
+ if (root === wd && filter == null) {
68
+ throw new Error("root path is workspace root, please provide a filter");
69
+ }
70
+ if (root === void 0) {
71
+ root = process$1.cwd();
72
+ }
73
+ if (root !== wd && filter == null) {
74
+ const packageJSONIsExist = fs.existsSync(path.resolve(root, "package.json"));
75
+ if (!packageJSONIsExist) {
76
+ throw new Error("root path is not workspace root, please provide a filter");
77
+ }
78
+ const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, "package.json"), "utf-8"));
79
+ if (packageJSON.name == null) {
80
+ throw new Error("root path is not workspace root, please provide a filter");
81
+ }
82
+ filter = packageJSON.name;
83
+ }
84
+ const { filterPackagesFromDir } = await import('@pnpm/filter-workspace-packages');
85
+ const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
86
+ filter: filter ?? "",
87
+ followProdDepsOnly: true
88
+ }], {
89
+ prefix: root,
90
+ workspaceDir: wd,
91
+ patterns: pnpmWorkspace.packages
92
+ });
93
+ return {
94
+ root,
95
+ value: Object.entries(selectedProjectsGraph).reduce((acc, [key, value]) => {
96
+ acc[key] = value.package.manifest;
97
+ return acc;
98
+ }, {})
99
+ };
100
+ }
101
+ throw new Error(`not supported package manager ${type}`);
102
+ }
103
+
104
+ export { getSelectedProjectsGraph as a, filterPackagesGraph as f, getWD as g, require as r, type as t };