@dcloudio/uni-cli-shared 3.0.0-alpha-3030220211217007 → 3.0.0-alpha-3030220211217008

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.
@@ -8,6 +8,7 @@ function initDefine(stringifyBoolean = false) {
8
8
  const isRunByHBuilderX = (0, env_1.runByHBuilderX)();
9
9
  const isDebug = !!manifestJson.debug;
10
10
  return {
11
+ ...initCustomDefine(),
11
12
  'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
12
13
  'process.env.UNI_DEBUG': stringifyBoolean
13
14
  ? JSON.stringify(isDebug)
@@ -29,3 +30,16 @@ function initDefine(stringifyBoolean = false) {
29
30
  };
30
31
  }
31
32
  exports.initDefine = initDefine;
33
+ function initCustomDefine() {
34
+ let define = {};
35
+ if (process.env.UNI_CUSTOM_DEFINE) {
36
+ try {
37
+ define = JSON.parse(process.env.UNI_CUSTOM_DEFINE);
38
+ }
39
+ catch (e) { }
40
+ }
41
+ return Object.keys(define).reduce((res, name) => {
42
+ res['process.env.' + name] = JSON.stringify(define[name]);
43
+ return res;
44
+ }, {});
45
+ }
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export * from './postcss';
18
18
  export * from './filter';
19
19
  export * from './esbuild';
20
20
  export * from './resolve';
21
+ export * from './scripts';
21
22
  export { M } from './messages';
22
23
  export * from './exports';
23
24
  export { checkUpdate } from './checkUpdate';
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ __exportStar(require("./postcss"), exports);
31
31
  __exportStar(require("./filter"), exports);
32
32
  __exportStar(require("./esbuild"), exports);
33
33
  __exportStar(require("./resolve"), exports);
34
+ __exportStar(require("./scripts"), exports);
34
35
  var messages_1 = require("./messages");
35
36
  Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
36
37
  __exportStar(require("./exports"), exports);
@@ -1,3 +1,3 @@
1
1
  export declare function getPreVueContext(): any;
2
2
  export declare function getPreNVueContext(): any;
3
- export declare function initPreContext(platform: UniApp.PLATFORM, userPreContext?: Record<string, boolean>): void;
3
+ export declare function initPreContext(platform: UniApp.PLATFORM, userPreContext?: Record<string, boolean> | string): void;
@@ -60,9 +60,17 @@ function initPreContext(platform, userPreContext) {
60
60
  defaultContext.QUICKAPP_WEBVIEW = true;
61
61
  }
62
62
  if (userPreContext) {
63
- Object.keys(userPreContext).forEach((key) => {
64
- defaultContext[normalizeKey(key)] = !!userPreContext[key];
65
- });
63
+ if ((0, shared_1.isString)(userPreContext)) {
64
+ try {
65
+ userPreContext = JSON.parse(userPreContext);
66
+ }
67
+ catch (e) { }
68
+ }
69
+ if ((0, shared_1.isPlainObject)(userPreContext)) {
70
+ Object.keys(userPreContext).forEach((key) => {
71
+ defaultContext[normalizeKey(key)] = !!userPreContext[key];
72
+ });
73
+ }
66
74
  }
67
75
  (0, shared_1.extend)(preVueContext, defaultContext, vueContext);
68
76
  (0, shared_1.extend)(preNVueContext, defaultContext, nvueContext);
@@ -0,0 +1,10 @@
1
+ export declare function parseScripts(name: string, pkgPath: string): {
2
+ name: string;
3
+ platform: keyof UniApp.PagesJsonPagePlatformStyle;
4
+ define: {
5
+ [name: string]: string;
6
+ };
7
+ context: {
8
+ [name: string]: boolean;
9
+ };
10
+ } | undefined;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parseScripts = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ function parseScripts(name, pkgPath) {
9
+ var _a, _b, _c;
10
+ if (!fs_1.default.existsSync(pkgPath)) {
11
+ return;
12
+ }
13
+ const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf8'));
14
+ const options = (_b = (_a = pkg['uni-app']) === null || _a === void 0 ? void 0 : _a.scripts) === null || _b === void 0 ? void 0 : _b[name];
15
+ if (!options) {
16
+ return;
17
+ }
18
+ if (!((_c = options.env) === null || _c === void 0 ? void 0 : _c.UNI_PLATFORM)) {
19
+ console.error(`package.json->uni-app->scripts->${name}->env->UNI_PLATFORM is required`);
20
+ process.exit(0);
21
+ }
22
+ const { UNI_PLATFORM, ...define } = options.env;
23
+ return {
24
+ name: name,
25
+ platform: UNI_PLATFORM,
26
+ define,
27
+ context: options.define || {},
28
+ };
29
+ }
30
+ exports.parseScripts = parseScripts;
@@ -381,9 +381,13 @@ function getTestTemplate(test) {
381
381
  return new Function("context", "with (context||{}){ return ( " + test + " ); }");
382
382
  }
383
383
 
384
- function testPasses(test,context) {
385
- var testFn = getTestTemplate(test);
386
- return testFn(context, getDeepPropFromObj);
384
+ // fixed by xxxxxx
385
+ function testPasses(test, context) {
386
+ var testFn = getTestTemplate(test)
387
+ try {
388
+ return testFn(context, getDeepPropFromObj)
389
+ } catch (e) {}
390
+ return false
387
391
  }
388
392
 
389
393
  function getFileContents(path, failSilent, requesterPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3030220211217007",
3
+ "version": "3.0.0-alpha-3030220211217008",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,9 +20,9 @@
20
20
  "dependencies": {
21
21
  "@babel/parser": "^7.16.4",
22
22
  "@babel/types": "^7.16.0",
23
- "@dcloudio/uni-i18n": "3.0.0-alpha-3030220211217007",
24
- "@dcloudio/uni-shared": "3.0.0-alpha-3030220211217007",
25
- "@rollup/pluginutils": "^4.1.1",
23
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3030220211217008",
24
+ "@dcloudio/uni-shared": "3.0.0-alpha-3030220211217008",
25
+ "@rollup/pluginutils": "^4.1.2",
26
26
  "@vue/compiler-core": "3.2.26",
27
27
  "@vue/compiler-dom": "3.2.26",
28
28
  "@vue/compiler-sfc": "3.2.26",
@@ -61,6 +61,6 @@
61
61
  "@types/mime": "^2.0.3",
62
62
  "@types/module-alias": "^2.0.1",
63
63
  "@types/stylus": "^0.48.36",
64
- "postcss": "^8.3.8"
64
+ "postcss": "^8.4.5"
65
65
  }
66
66
  }