@unisphere/cli 1.44.1 → 1.44.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.
@@ -87,9 +87,9 @@ module.exports = (unisphereConfig) => {
87
87
  const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, 'utf8'));
88
88
  const sourcePath = projectJson.sourceRoot.replace(/\/src$/, '').split('/');
89
89
  if (sourcePath.length !== 3 || sourcePath[0] !== 'unisphere' || sourcePath[1] !== 'packages') {
90
- throw new Error('sourcePath follow pattern unisphere/packages/<package-name>')
90
+ throw new Error('sourcePath must follow pattern unisphere/packages/<package-name>')
91
91
  }
92
- const outputPath = `../../../dist/${sourcePath.join('/')}`;
92
+ const outputPath = path.join('..', '..', '..', 'dist', ...sourcePath);
93
93
 
94
94
 
95
95
  return withUnisphere(withNx(
@@ -56,8 +56,8 @@ const getWithNx = (unisphereConfig) => {
56
56
 
57
57
  const relativeSourcePath = path.relative(unisphereConfig.cwd, unisphereConfig.workspaceConfiguration.cwd);
58
58
 
59
- const outputPath = `${relativeSourcePath}/dist/${unisphereConfig.sourcePath.join('/')}`;
60
-
59
+ const outputPath = path.join(relativeSourcePath, 'dist', ...unisphereConfig.sourcePath);
60
+
61
61
  const firstArgument = {
62
62
  main: './src/index.ts',
63
63
  outputPath,
@@ -80,10 +80,10 @@ const getWithNx = (unisphereConfig) => {
80
80
  }),
81
81
  ]
82
82
  }
83
-
83
+
84
84
  if (isDeployingRuntime) {
85
85
  const unispherePackagesDistList = getUnispherePackagesDistList(unisphereConfig.workspaceConfiguration.cwd);
86
-
86
+
87
87
  secondArgument.unisphere = getUnisphereTSInterceptorsConfig(unispherePackagesDistList);
88
88
  return withUnisphere(withNx(
89
89
  firstArgument,
@@ -99,8 +99,12 @@ const getWithNx = (unisphereConfig) => {
99
99
 
100
100
  function getUnispherePackagesDistList(cwd) {
101
101
 
102
- const folderPattern = path.resolve(cwd, 'dist/unisphere/packages/*');
103
-
102
+ let folderPattern = path.join(cwd, 'dist', 'unisphere', 'packages', '*');
103
+
104
+ if (process.platform === 'win32') {
105
+ console.log('[unisphere] running on Windows');
106
+ folderPattern = folderPattern.replace(/\//g, '\\');
107
+ }
104
108
  console.log('[unisphere] looking for packages in', folderPattern);
105
109
  const folderPaths = glob.sync(folderPattern);
106
110
  const result = [];
@@ -125,24 +129,24 @@ function getUnispherePackagesDistList(cwd) {
125
129
  }
126
130
 
127
131
  const withUnisphere = (rollupConfig, unispherePackagesDistList) => {
128
-
132
+
129
133
  console.log('[unisphere] removing unisphere config used to monkey patch @nw/rollup');
130
134
  delete rollupConfig.unisphere;
131
-
135
+
132
136
  rollupConfig.onwarn = (warning, warn) => {
133
137
  if (warning.code === 'THIS_IS_UNDEFINED') return;
134
138
  if (warning.code === 'MODULE_LEVEL_DIRECTIVE') return;
135
139
  warn(warning); // this requires Rollup 0.46
136
140
  };
137
-
141
+
138
142
  rollupConfig.external = [];
139
-
143
+
140
144
  if (isProduction) {
141
145
  rollupConfig.output[0].entryFileNames = 'index.esm.js'
142
146
  } else {
143
147
  rollupConfig.output[0].entryFileNames = 'index.dev.esm.js'
144
148
  }
145
-
149
+
146
150
  rollupConfig.plugins.push(
147
151
  alias({
148
152
  entries: unispherePackagesDistList.map(item => {
@@ -162,24 +166,24 @@ const withUnisphere = (rollupConfig, unispherePackagesDistList) => {
162
166
  }),
163
167
  isProduction ? terser() : undefined
164
168
  );
165
-
166
-
169
+
170
+
167
171
  return rollupConfig;
168
172
  };
169
-
170
-
173
+
174
+
171
175
 
172
176
 
173
177
  module.exports = (unisphereConfig) => {
174
178
 
175
179
  console.log('[unisphere] unisphere rollup args before stripping', unisphereConfig);
176
-
180
+
177
181
  const workspaceConfiguration = getUnisphereWorkspaceFile(unisphereConfig.cwd);
178
182
 
179
183
  if (!workspaceConfiguration) {
180
184
  throw new Error('the library must be run from the root of the unisphere workspace');
181
185
  }
182
-
186
+
183
187
  const projectJsonPath = path.join(unisphereConfig.cwd, 'project.json');
184
188
 
185
189
  const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, 'utf8'));
@@ -190,7 +194,7 @@ module.exports = (unisphereConfig) => {
190
194
  if (!pathCheck || sourcePath[0] !== 'unisphere' || sourcePath[1] !== expectedType) {
191
195
  throw new Error(`sourcePath must follow pattern unisphere/${expectedType}/<runtime-name>, got ${sourcePath.join('/')}`)
192
196
  }
193
-
197
+
194
198
  // todo can improve code readability by moving the calculation of the 'outputPath' here instead of in getWithNx
195
199
  return getWithNx(
196
200
  {
@@ -199,4 +203,4 @@ module.exports = (unisphereConfig) => {
199
203
  sourcePath
200
204
  }
201
205
  );
202
- }
206
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisphere/cli",
3
- "version": "1.44.1",
3
+ "version": "1.44.3",
4
4
  "bin": {
5
5
  "unisphere": "./src/cli.js"
6
6
  },
package/src/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './lib/utils/unisphere/workspace';
2
2
  export * from './lib/utils';
3
3
  export * from './lib/utils/get-cli-version';
4
4
  export * from './lib/utils/unisphere/get-global-file';
5
+ export * from './lib/utils/unisphere/get-widget-name';
package/src/index.js CHANGED
@@ -5,4 +5,5 @@ tslib_1.__exportStar(require("./lib/utils/unisphere/workspace"), exports);
5
5
  tslib_1.__exportStar(require("./lib/utils"), exports);
6
6
  tslib_1.__exportStar(require("./lib/utils/get-cli-version"), exports);
7
7
  tslib_1.__exportStar(require("./lib/utils/unisphere/get-global-file"), exports);
8
+ tslib_1.__exportStar(require("./lib/utils/unisphere/get-widget-name"), exports);
8
9
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/unisphere-cli/src/index.ts"],"names":[],"mappings":";;;AAAA,0EAAgD;AAChD,sDAA4B;AAC5B,sEAA4C;AAC5C,gFAAsD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/unisphere-cli/src/index.ts"],"names":[],"mappings":";;;AAAA,0EAAgD;AAChD,sDAA4B;AAC5B,sEAA4C;AAC5C,gFAAsD;AACtD,gFAAsD"}
@@ -13,6 +13,7 @@ const colorette_3 = require("colorette");
13
13
  const prompts_1 = require("../../utils/prompts/prompts");
14
14
  const fs = require("fs");
15
15
  const workspace_1 = require("../../utils/unisphere/workspace");
16
+ const build_widget_name_from_workspace_info_1 = require("../../utils/build-widget-name-from-workspace-info");
16
17
  const debug = (0, debug_1.default)('unisphere:init');
17
18
  const createInitCommand = () => {
18
19
  const initCommand = new commander_1.Command('init');
@@ -33,7 +34,7 @@ const createInitCommand = () => {
33
34
  if (!workspaceFile) {
34
35
  (0, prompts_1.logErrorAndRethrow)(`No .unisphere file found in the widget directory`);
35
36
  }
36
- const widgetName = `${workspaceFile.config.company}.${workspaceFile.config.type || 'widget'}.${workspaceFile.config.name}`;
37
+ const widgetName = (0, build_widget_name_from_workspace_info_1.buildWidgetNameFromWorkspaceInfo)(workspaceFile);
37
38
  const globalFile = (0, get_global_file_1.getGlobalFile)();
38
39
  globalFile.projects[widgetName] = { cwd };
39
40
  (0, get_global_file_1.setGlobalFile)(globalFile);
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/commands/init/command.ts"],"names":[],"mappings":";;;;AAAA,yCAAoC;AACpC,6CAAqD;AACrD,mCAAmC;AACnC,iCAA0B;AAC1B,2EAG+C;AAC/C,yCAAuC;AACvC,yCAAiC;AACjC,yCAAgC;AAChC,yDAA2E;AAC3E,yBAAyB;AACzB,+DAAwE;AAExE,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,gBAAgB,CAAC,CAAC;AAE/B,MAAM,iBAAiB,GAAG,GAAY,EAAE;IAC7C,MAAM,WAAW,GAAG,IAAI,mBAAO,CAAC,MAAM,CAAC,CAAC;IAExC,WAAW;SACR,WAAW,CAAC,gCAAgC,CAAC;SAC7C,MAAM,CAAC,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,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAxCW,QAAA,iBAAiB,qBAwC5B"}
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/commands/init/command.ts"],"names":[],"mappings":";;;;AAAA,yCAAoC;AACpC,6CAAqD;AACrD,mCAAmC;AACnC,iCAA0B;AAC1B,2EAG+C;AAC/C,yCAAuC;AACvC,yCAAiC;AACjC,yCAAgC;AAChC,yDAA2E;AAC3E,yBAAyB;AACzB,+DAAwE;AACxE,6GAAqG;AAErG,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,gBAAgB,CAAC,CAAC;AAE/B,MAAM,iBAAiB,GAAG,GAAY,EAAE;IAC7C,MAAM,WAAW,GAAG,IAAI,mBAAO,CAAC,MAAM,CAAC,CAAC;IAExC,WAAW;SACR,WAAW,CAAC,gCAAgC,CAAC;SAC7C,MAAM,CAAC,WAAW,EAAE,mBAAmB,EAAE,KAAK,CAAC;SAC/C,MAAM,CAAC,cAAc,EAAE,8BAA8B,CAAC;SACtD,IAAI,CAAC,WAAW,EAAE,wBAAgB,CAAC;SACnC,MAAM,CAAC,CAAO,OAAO,EAAE,EAAE;QACxB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAA,eAAG,EAAC,2BAA2B,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAExD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACvB,IAAA,4BAAkB,EAAC,6BAA6B,GAAG,EAAE,CAAC,CAAC;SACxD;QAED,MAAM,aAAa,GAAG,MAAM,IAAA,iCAAqB,EAAC,GAAG,EAAE;YACrD,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,EAAE;YAClB,IAAA,4BAAkB,EAAC,kDAAkD,CAAC,CAAC;SACxE;QAED,MAAM,UAAU,GAAG,IAAA,wEAAgC,EAAC,aAAa,CAAC,CAAC;QAEnE,MAAM,UAAU,GAAG,IAAA,+BAAa,GAAE,CAAC;QACnC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;QAC1C,IAAA,+BAAa,EAAC,UAAU,CAAC,CAAC;QAE1B,OAAO,CAAC,GAAG,CACT,GAAG,IAAA,iBAAK,EAAC,GAAG,CAAC,IAAI,IAAA,gBAAI,EAAC,uBAAuB,UAAU,GAAG,CAAC,IAAI,IAAA,kBAAQ,EACrE,IAAI,CACL,IAAI,IAAA,eAAG,EAAC,GAAG,CAAC,EAAE,CAChB,CAAC;IACJ,CAAC,CAAA,CAAC,CAAC;IAEL,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAtCW,QAAA,iBAAiB,qBAsC5B"}
@@ -0,0 +1,2 @@
1
+ import { UnisphereWorkspace } from "./unisphere/types";
2
+ export declare const buildWidgetNameFromWorkspaceInfo: (workspaceFile: UnisphereWorkspace) => string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildWidgetNameFromWorkspaceInfo = void 0;
4
+ const buildWidgetNameFromWorkspaceInfo = (workspaceFile) => {
5
+ return `${workspaceFile.config.company}.${workspaceFile.config.type || 'widget'}.${workspaceFile.config.name}`;
6
+ };
7
+ exports.buildWidgetNameFromWorkspaceInfo = buildWidgetNameFromWorkspaceInfo;
8
+ //# sourceMappingURL=build-widget-name-from-workspace-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-widget-name-from-workspace-info.js","sourceRoot":"","sources":["../../../../../../packages/unisphere-cli/src/lib/utils/build-widget-name-from-workspace-info.ts"],"names":[],"mappings":";;;AAEO,MAAM,gCAAgC,GAAG,CAAC,aAAiC,EAAU,EAAE;IAC5F,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,OAAO,IACpC,aAAa,CAAC,MAAM,CAAC,IAAI,IAAI,QAC/B,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AAClC,CAAC,CAAC;AAJW,QAAA,gCAAgC,oCAI3C"}
@@ -0,0 +1 @@
1
+ export declare const getWidgetName: (cwd: string) => Promise<string>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWidgetName = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const build_widget_name_from_workspace_info_1 = require("../build-widget-name-from-workspace-info");
6
+ const workspace_1 = require("./workspace");
7
+ const getWidgetName = (cwd) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
8
+ const workspaceFile = yield (0, workspace_1.getUnisphereWorkspace)(cwd, {
9
+ suspendRecursion: true,
10
+ });
11
+ if (!workspaceFile) {
12
+ throw new Error('No .unisphere file found in the widget directory');
13
+ }
14
+ return (0, build_widget_name_from_workspace_info_1.buildWidgetNameFromWorkspaceInfo)(workspaceFile);
15
+ });
16
+ exports.getWidgetName = getWidgetName;
17
+ //# sourceMappingURL=get-widget-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-widget-name.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/utils/unisphere/get-widget-name.ts"],"names":[],"mappings":";;;;AAAI,oGAA4F;AAChG,2CAAoD;AAE7C,MAAM,aAAa,GAAG,CAAO,GAAW,EAAmB,EAAE;IAClE,MAAM,aAAa,GAAG,MAAM,IAAA,iCAAqB,EAAC,GAAG,EAAE;QACrD,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;KACrE;IAED,OAAO,IAAA,wEAAgC,EAAC,aAAa,CAAC,CAAC;AACzD,CAAC,CAAA,CAAC;AAVW,QAAA,aAAa,iBAUxB"}