@dcloudio/uni-cli-shared 3.0.0-alpha-3021320211118002 → 3.0.0-alpha-3021320211119001

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.
@@ -1,3 +1,5 @@
1
1
  import type { Formatter } from '../logs/format';
2
2
  export declare function initModuleAlias(): void;
3
+ export declare function installHBuilderXPlugin(plugin: string): void;
3
4
  export declare const moduleAliasFormatter: Formatter;
5
+ export declare function formatInstallHBuilderXPluginTips(lang: string, preprocessor: string): string;
package/dist/hbx/alias.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.moduleAliasFormatter = exports.initModuleAlias = void 0;
6
+ exports.formatInstallHBuilderXPluginTips = exports.moduleAliasFormatter = exports.installHBuilderXPlugin = exports.initModuleAlias = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const module_alias_1 = __importDefault(require("module-alias"));
9
9
  const env_1 = require("./env");
@@ -25,9 +25,13 @@ exports.initModuleAlias = initModuleAlias;
25
25
  function supportAutoInstallPlugin() {
26
26
  return true;
27
27
  }
28
- function sendSignal(lang) {
29
- return console.error(`%HXRunUniAPPPluginName%${lang}%HXRunUniAPPPluginName%`);
28
+ function installHBuilderXPlugin(plugin) {
29
+ if (!supportAutoInstallPlugin()) {
30
+ return;
31
+ }
32
+ return console.error(`%HXRunUniAPPPluginName%${plugin}%HXRunUniAPPPluginName%`);
30
33
  }
34
+ exports.installHBuilderXPlugin = installHBuilderXPlugin;
31
35
  exports.moduleAliasFormatter = {
32
36
  test(msg) {
33
37
  return msg.includes('Preprocessor dependency');
@@ -48,11 +52,14 @@ exports.moduleAliasFormatter = {
48
52
  preprocessor = 'compile-stylus';
49
53
  }
50
54
  if (lang) {
51
- const autoInstall = supportAutoInstallPlugin();
52
- autoInstall && sendSignal(preprocessor);
53
- return `预编译器错误:代码使用了${lang}语言,但未安装相应的编译器插件,${autoInstall ? '正在从' : '请前往'}插件市场安装该插件:
54
- https://ext.dcloud.net.cn/plugin?name=${preprocessor}`;
55
+ installHBuilderXPlugin(preprocessor);
56
+ return formatInstallHBuilderXPluginTips(lang, preprocessor);
55
57
  }
56
58
  return msg;
57
59
  },
58
60
  };
61
+ function formatInstallHBuilderXPluginTips(lang, preprocessor) {
62
+ return `预编译器错误:代码使用了${lang}语言,但未安装相应的编译器插件,${supportAutoInstallPlugin() ? '正在从' : '请前往'}插件市场安装该插件:
63
+ https://ext.dcloud.net.cn/plugin?name=${preprocessor}`;
64
+ }
65
+ exports.formatInstallHBuilderXPluginTips = formatInstallHBuilderXPluginTips;
@@ -1,2 +1,2 @@
1
1
  export * from './env';
2
- export { initModuleAlias } from './alias';
2
+ export { initModuleAlias, installHBuilderXPlugin, formatInstallHBuilderXPluginTips, } from './alias';
package/dist/hbx/index.js CHANGED
@@ -10,7 +10,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.initModuleAlias = void 0;
13
+ exports.formatInstallHBuilderXPluginTips = exports.installHBuilderXPlugin = exports.initModuleAlias = void 0;
14
14
  __exportStar(require("./env"), exports);
15
15
  var alias_1 = require("./alias");
16
16
  Object.defineProperty(exports, "initModuleAlias", { enumerable: true, get: function () { return alias_1.initModuleAlias; } });
17
+ Object.defineProperty(exports, "installHBuilderXPlugin", { enumerable: true, get: function () { return alias_1.installHBuilderXPlugin; } });
18
+ Object.defineProperty(exports, "formatInstallHBuilderXPluginTips", { enumerable: true, get: function () { return alias_1.formatInstallHBuilderXPluginTips; } });
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export * from './preprocess';
16
16
  export * from './postcss';
17
17
  export * from './filter';
18
18
  export * from './esbuild';
19
+ export * from './resolve';
19
20
  export { M } from './messages';
20
21
  export * from './exports';
21
22
  export { checkUpdate } from './checkUpdate';
package/dist/index.js CHANGED
@@ -29,6 +29,7 @@ __exportStar(require("./preprocess"), exports);
29
29
  __exportStar(require("./postcss"), exports);
30
30
  __exportStar(require("./filter"), exports);
31
31
  __exportStar(require("./esbuild"), exports);
32
+ __exportStar(require("./resolve"), exports);
32
33
  var messages_1 = require("./messages");
33
34
  Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
34
35
  __exportStar(require("./exports"), exports);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.hasJsonFile = exports.isPageFile = void 0;
4
4
  const shared_1 = require("@vue/shared");
5
5
  const utils_1 = require("../../utils");
6
+ const resolve_1 = require("../../resolve");
6
7
  let appJsonCache = {};
7
8
  const jsonFilesCache = new Map();
8
9
  const jsonPagesCache = new Map();
@@ -33,7 +34,7 @@ function findChangedJsonFiles() {
33
34
  const usingComponents = newJson.usingComponents;
34
35
  // 格式化为相对路径,这样作为分包也可以直接运行
35
36
  Object.keys(usingComponents).forEach((name) => {
36
- usingComponents[name] = (0, utils_1.relativeFile)(filename, usingComponents[name].slice(1));
37
+ usingComponents[name] = (0, resolve_1.relativeFile)(filename, usingComponents[name].slice(1));
37
38
  });
38
39
  const jsonStr = JSON.stringify(newJson, null, 2);
39
40
  if (jsonFilesCache.get(filename) !== jsonStr) {
@@ -18,6 +18,7 @@ const DEFAULT_KEYS = [
18
18
  'MP_TOUTIAO',
19
19
  'MP_WEIXIN',
20
20
  'MP_KUAISHOU',
21
+ 'MP_JD',
21
22
  'QUICKAPP_NATIVE',
22
23
  'QUICKAPP_WEBVIEW',
23
24
  'QUICKAPP_WEBVIEW_HUAWEI',
@@ -0,0 +1,5 @@
1
+ export declare function relativeFile(from: string, to: string): string;
2
+ export declare const resolveMainPathOnce: (inputDir: string) => string;
3
+ export declare function getBuiltInPaths(): string[];
4
+ export declare function resolveBuiltIn(path: string): string;
5
+ export declare function resolveComponentsLibPath(): string;
@@ -0,0 +1,89 @@
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.resolveComponentsLibPath = exports.resolveBuiltIn = exports.getBuiltInPaths = exports.resolveMainPathOnce = exports.relativeFile = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const debug_1 = __importDefault(require("debug"));
10
+ const resolve_1 = __importDefault(require("resolve"));
11
+ const uni_shared_1 = require("@dcloudio/uni-shared");
12
+ const utils_1 = require("./utils");
13
+ const DEFAULT_EXTENSIONS = ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'];
14
+ function resolveWithSymlinks(id, basedir) {
15
+ return resolve_1.default.sync(id, {
16
+ basedir,
17
+ extensions: DEFAULT_EXTENSIONS,
18
+ // necessary to work with pnpm
19
+ preserveSymlinks: true,
20
+ });
21
+ }
22
+ function relativeFile(from, to) {
23
+ const relativePath = (0, utils_1.normalizePath)(path_1.default.relative(path_1.default.dirname(from), to));
24
+ return relativePath.startsWith('.') ? relativePath : './' + relativePath;
25
+ }
26
+ exports.relativeFile = relativeFile;
27
+ exports.resolveMainPathOnce = (0, uni_shared_1.once)((inputDir) => {
28
+ const mainTsPath = path_1.default.resolve(inputDir, 'main.ts');
29
+ if (fs_1.default.existsSync(mainTsPath)) {
30
+ return (0, utils_1.normalizePath)(mainTsPath);
31
+ }
32
+ return (0, utils_1.normalizePath)(path_1.default.resolve(inputDir, 'main.js'));
33
+ });
34
+ const ownerModules = ['@dcloudio/uni-app', '@dcloudio/vite-plugin-uni'];
35
+ const paths = [];
36
+ function resolveNodeModulePath(modulePath) {
37
+ const nodeModulesPaths = [];
38
+ const nodeModulesPath = path_1.default.join(modulePath, 'node_modules');
39
+ if (fs_1.default.existsSync(nodeModulesPath)) {
40
+ nodeModulesPaths.push(nodeModulesPath);
41
+ }
42
+ const index = modulePath.lastIndexOf('node_modules');
43
+ if (index > -1) {
44
+ nodeModulesPaths.push(path_1.default.join(modulePath.substr(0, index), 'node_modules'));
45
+ }
46
+ return nodeModulesPaths;
47
+ }
48
+ function initPaths() {
49
+ const cliContext = process.env.UNI_CLI_CONTEXT;
50
+ if (cliContext) {
51
+ const pathSet = new Set();
52
+ pathSet.add(path_1.default.join(cliContext, 'node_modules'));
53
+ [`@dcloudio/uni-` + process.env.UNI_PLATFORM, ...ownerModules].forEach((ownerModule) => {
54
+ let pkgPath = '';
55
+ try {
56
+ pkgPath = require.resolve(ownerModule + '/package.json', {
57
+ paths: [cliContext],
58
+ });
59
+ }
60
+ catch (e) { }
61
+ if (pkgPath) {
62
+ resolveNodeModulePath(path_1.default.dirname(pkgPath)).forEach((nodeModulePath) => {
63
+ pathSet.add(nodeModulePath);
64
+ });
65
+ }
66
+ });
67
+ paths.push(...pathSet);
68
+ (0, debug_1.default)('uni-paths')(paths);
69
+ }
70
+ }
71
+ function getBuiltInPaths() {
72
+ if (!paths.length) {
73
+ initPaths();
74
+ }
75
+ return paths;
76
+ }
77
+ exports.getBuiltInPaths = getBuiltInPaths;
78
+ function resolveBuiltIn(path) {
79
+ return require.resolve(path, { paths: getBuiltInPaths() });
80
+ }
81
+ exports.resolveBuiltIn = resolveBuiltIn;
82
+ let componentsLibPath = '';
83
+ function resolveComponentsLibPath() {
84
+ if (!componentsLibPath) {
85
+ componentsLibPath = path_1.default.join(resolveWithSymlinks('@dcloudio/uni-components/package.json', process.env.UNI_INPUT_DIR), '../lib');
86
+ }
87
+ return componentsLibPath;
88
+ }
89
+ exports.resolveComponentsLibPath = resolveComponentsLibPath;
package/dist/utils.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  export { default as hash } from 'hash-sum';
2
2
  import type { SFCTemplateCompileOptions } from '@vue/compiler-sfc';
3
3
  import { ElementNode, RootNode, TemplateChildNode } from '@vue/compiler-core';
4
+ export declare let isRunningWithYarnPnp: boolean;
4
5
  export declare const isWindows: boolean;
5
6
  export declare function normalizePath(id: string): string;
6
- export declare function relativeFile(from: string, to: string): string;
7
7
  export declare function checkElementNodeTag(node: RootNode | TemplateChildNode | null | undefined, tag: string): node is ElementNode;
8
- export declare const resolveMainPathOnce: (inputDir: string) => string;
9
- export declare function resolveComponentsLibPath(): string;
10
- export declare function getBuiltInPaths(): string[];
11
- export declare function resolveBuiltIn(path: string): string;
12
8
  export declare function normalizeIdentifier(str: string): string;
13
9
  export declare function normalizePagePath(pagePath: string, platform: UniApp.PLATFORM): string | undefined;
14
10
  export declare function removeExt(str: string): string;
package/dist/utils.js CHANGED
@@ -3,92 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createUniVueTransformAssetUrls = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.resolveBuiltIn = exports.getBuiltInPaths = exports.resolveComponentsLibPath = exports.resolveMainPathOnce = exports.checkElementNodeTag = exports.relativeFile = exports.normalizePath = exports.isWindows = exports.hash = void 0;
6
+ exports.createUniVueTransformAssetUrls = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.hash = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const shared_1 = require("@vue/shared");
11
- const uni_shared_1 = require("@dcloudio/uni-shared");
12
11
  var hash_sum_1 = require("hash-sum");
13
12
  Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return __importDefault(hash_sum_1).default; } });
14
- const debug_1 = __importDefault(require("debug"));
15
13
  const constants_1 = require("./constants");
14
+ try {
15
+ exports.isRunningWithYarnPnp = Boolean(require('pnpapi'));
16
+ }
17
+ catch (_a) { }
16
18
  exports.isWindows = os_1.default.platform() === 'win32';
17
19
  function normalizePath(id) {
18
20
  return exports.isWindows ? id.replace(/\\/g, '/') : id;
19
21
  }
20
22
  exports.normalizePath = normalizePath;
21
- function relativeFile(from, to) {
22
- return normalizePath(path_1.default.relative(path_1.default.dirname(from), to));
23
- }
24
- exports.relativeFile = relativeFile;
25
23
  function checkElementNodeTag(node, tag) {
26
24
  return !!node && node.type === 1 /* ELEMENT */ && node.tag === tag;
27
25
  }
28
26
  exports.checkElementNodeTag = checkElementNodeTag;
29
- exports.resolveMainPathOnce = (0, uni_shared_1.once)((inputDir) => {
30
- const mainTsPath = path_1.default.resolve(inputDir, 'main.ts');
31
- if (fs_1.default.existsSync(mainTsPath)) {
32
- return normalizePath(mainTsPath);
33
- }
34
- return normalizePath(path_1.default.resolve(inputDir, 'main.js'));
35
- });
36
- let componentsLibPath = '';
37
- function resolveComponentsLibPath() {
38
- if (!componentsLibPath) {
39
- componentsLibPath = path_1.default.resolve(resolveBuiltIn('@dcloudio/uni-components/package.json'), '../lib');
40
- }
41
- return componentsLibPath;
42
- }
43
- exports.resolveComponentsLibPath = resolveComponentsLibPath;
44
- const ownerModules = ['@dcloudio/uni-app', '@dcloudio/vite-plugin-uni'];
45
- const paths = [];
46
- function resolveNodeModulePath(modulePath) {
47
- const nodeModulesPaths = [];
48
- const nodeModulesPath = path_1.default.join(modulePath, 'node_modules');
49
- if (fs_1.default.existsSync(nodeModulesPath)) {
50
- nodeModulesPaths.push(nodeModulesPath);
51
- }
52
- const index = modulePath.lastIndexOf('node_modules');
53
- if (index > -1) {
54
- nodeModulesPaths.push(path_1.default.join(modulePath.substr(0, index), 'node_modules'));
55
- }
56
- return nodeModulesPaths;
57
- }
58
- function initPaths() {
59
- const cliContext = process.env.UNI_CLI_CONTEXT;
60
- if (cliContext) {
61
- const pathSet = new Set();
62
- pathSet.add(path_1.default.join(cliContext, 'node_modules'));
63
- [`@dcloudio/uni-` + process.env.UNI_PLATFORM, ...ownerModules].forEach((ownerModule) => {
64
- let pkgPath = '';
65
- try {
66
- pkgPath = require.resolve(ownerModule + '/package.json', {
67
- paths: [cliContext],
68
- });
69
- }
70
- catch (e) { }
71
- if (pkgPath) {
72
- resolveNodeModulePath(path_1.default.dirname(pkgPath)).forEach((nodeModulePath) => {
73
- pathSet.add(nodeModulePath);
74
- });
75
- }
76
- });
77
- paths.push(...pathSet);
78
- (0, debug_1.default)('uni-paths')(paths);
79
- }
80
- }
81
- function getBuiltInPaths() {
82
- if (!paths.length) {
83
- initPaths();
84
- }
85
- return paths;
86
- }
87
- exports.getBuiltInPaths = getBuiltInPaths;
88
- function resolveBuiltIn(path) {
89
- return require.resolve(path, { paths: getBuiltInPaths() });
90
- }
91
- exports.resolveBuiltIn = resolveBuiltIn;
92
27
  function normalizeIdentifier(str) {
93
28
  return (0, shared_1.capitalize)((0, shared_1.camelize)(str.replace(/\//g, '-')));
94
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3021320211118002",
3
+ "version": "3.0.0-alpha-3021320211119001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "dependencies": {
21
21
  "@babel/parser": "^7.15.0",
22
22
  "@babel/types": "^7.15.0",
23
- "@dcloudio/uni-i18n": "3.0.0-alpha-3021320211118002",
24
- "@dcloudio/uni-shared": "3.0.0-alpha-3021320211118002",
23
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3021320211119001",
24
+ "@dcloudio/uni-shared": "3.0.0-alpha-3021320211119001",
25
25
  "@rollup/pluginutils": "^4.1.1",
26
26
  "@vue/compiler-core": "3.2.22",
27
27
  "@vue/compiler-dom": "3.2.22",
@@ -44,6 +44,7 @@
44
44
  "postcss-import": "^14.0.2",
45
45
  "postcss-load-config": "^3.1.0",
46
46
  "postcss-selector-parser": "^6.0.6",
47
+ "resolve": "^1.20.0",
47
48
  "rollup-plugin-copy": "^3.4.0",
48
49
  "tapable": "^2.2.0",
49
50
  "xregexp": "3.1.0"