xhs-mp-compiler-cli 1.1.2 → 1.1.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.
Files changed (118) hide show
  1. package/package.json +2 -2
  2. package/dist/bin/xhs-mp-cli-build.d.ts +0 -2
  3. package/dist/bin/xhs-mp-cli-build.js +0 -40
  4. package/dist/bin/xhs-mp-cli-dev.d.ts +0 -2
  5. package/dist/bin/xhs-mp-cli-dev.js +0 -59
  6. package/dist/bin/xhs-mp-cli.d.ts +0 -2
  7. package/dist/bin/xhs-mp-cli.js +0 -16
  8. package/dist/compiler.d.ts +0 -76
  9. package/dist/compiler.js +0 -361
  10. package/dist/compilerCP.d.ts +0 -1
  11. package/dist/compilerCP.js +0 -175
  12. package/dist/config/constant.config.d.ts +0 -27
  13. package/dist/config/constant.config.js +0 -30
  14. package/dist/config/dir.config.d.ts +0 -3
  15. package/dist/config/dir.config.js +0 -16
  16. package/dist/index.d.ts +0 -84
  17. package/dist/index.js +0 -454
  18. package/dist/packs/index.d.ts +0 -14
  19. package/dist/packs/index.js +0 -31
  20. package/dist/packs/mp-pack/index.d.ts +0 -3
  21. package/dist/packs/mp-pack/index.js +0 -32
  22. package/dist/packs/webpack/dev-server/index.d.ts +0 -3
  23. package/dist/packs/webpack/dev-server/index.js +0 -64
  24. package/dist/packs/webpack/dev-server/lib/ensurePort.d.ts +0 -2
  25. package/dist/packs/webpack/dev-server/lib/ensurePort.js +0 -32
  26. package/dist/packs/webpack/dev-server/lib/openBrowser.d.ts +0 -2
  27. package/dist/packs/webpack/dev-server/lib/openBrowser.js +0 -23
  28. package/dist/packs/webpack/dev-server/lib/openChrome.applescript +0 -78
  29. package/dist/packs/webpack/index.d.ts +0 -3
  30. package/dist/packs/webpack/index.js +0 -92
  31. package/dist/packs/webpack/webpack.d.ts +0 -21
  32. package/dist/packs/webpack/webpack.js +0 -79
  33. package/dist/presets/babel.d.ts +0 -8
  34. package/dist/presets/babel.js +0 -59
  35. package/dist/presets/common.d.ts +0 -4
  36. package/dist/presets/common.js +0 -48
  37. package/dist/presets/configs/minigame/assets/assetsEntryPlugin.d.ts +0 -10
  38. package/dist/presets/configs/minigame/assets/assetsEntryPlugin.js +0 -46
  39. package/dist/presets/configs/minigame/assets/index.d.ts +0 -3
  40. package/dist/presets/configs/minigame/assets/index.js +0 -65
  41. package/dist/presets/configs/minigame/service/index.d.ts +0 -3
  42. package/dist/presets/configs/minigame/service/index.js +0 -34
  43. package/dist/presets/configs/minigame/service/resolveLimitPlugin.d.ts +0 -8
  44. package/dist/presets/configs/minigame/service/resolveLimitPlugin.js +0 -35
  45. package/dist/presets/configs/minigame/service/serviceChunkPlugin.d.ts +0 -9
  46. package/dist/presets/configs/minigame/service/serviceChunkPlugin.js +0 -69
  47. package/dist/presets/configs/minigame/service/serviceEntryPlugin.d.ts +0 -10
  48. package/dist/presets/configs/minigame/service/serviceEntryPlugin.js +0 -32
  49. package/dist/presets/configs/miniprogram/assets/assetsEntryPlugin.d.ts +0 -12
  50. package/dist/presets/configs/miniprogram/assets/assetsEntryPlugin.js +0 -132
  51. package/dist/presets/configs/miniprogram/assets/index.d.ts +0 -4
  52. package/dist/presets/configs/miniprogram/assets/index.js +0 -47
  53. package/dist/presets/configs/miniprogram/render/component.d.ts +0 -3
  54. package/dist/presets/configs/miniprogram/render/component.js +0 -47
  55. package/dist/presets/configs/miniprogram/render/index.d.ts +0 -5
  56. package/dist/presets/configs/miniprogram/render/index.js +0 -71
  57. package/dist/presets/configs/miniprogram/render/render.d.ts +0 -3
  58. package/dist/presets/configs/miniprogram/render/render.js +0 -49
  59. package/dist/presets/configs/miniprogram/render/renderChunkPlugin.d.ts +0 -8
  60. package/dist/presets/configs/miniprogram/render/renderChunkPlugin.js +0 -55
  61. package/dist/presets/configs/miniprogram/render/sjsEntryPlugin.d.ts +0 -15
  62. package/dist/presets/configs/miniprogram/render/sjsEntryPlugin.js +0 -163
  63. package/dist/presets/configs/miniprogram/service/index.d.ts +0 -5
  64. package/dist/presets/configs/miniprogram/service/index.js +0 -72
  65. package/dist/presets/configs/miniprogram/service/resolveLimitPlugin.d.ts +0 -8
  66. package/dist/presets/configs/miniprogram/service/resolveLimitPlugin.js +0 -66
  67. package/dist/presets/configs/miniprogram/service/serviceChunkPlugin.d.ts +0 -9
  68. package/dist/presets/configs/miniprogram/service/serviceChunkPlugin.js +0 -65
  69. package/dist/presets/index.d.ts +0 -2
  70. package/dist/presets/index.js +0 -95
  71. package/dist/presets/loaders/mg-entry-loader.d.ts +0 -1
  72. package/dist/presets/loaders/mg-entry-loader.js +0 -27
  73. package/dist/presets/loaders/mini-style-loader.d.ts +0 -1
  74. package/dist/presets/loaders/mini-style-loader.js +0 -72
  75. package/dist/presets/loaders/mp-entry-loader.d.ts +0 -1
  76. package/dist/presets/loaders/mp-entry-loader.js +0 -196
  77. package/dist/presets/loaders/sjs-loader/index.d.ts +0 -12
  78. package/dist/presets/loaders/sjs-loader/index.js +0 -605
  79. package/dist/presets/loaders/sjs-loader/scope.d.ts +0 -36
  80. package/dist/presets/loaders/sjs-loader/scope.js +0 -122
  81. package/dist/presets/loaders/sjs-loader/tranform.d.ts +0 -2
  82. package/dist/presets/loaders/sjs-loader/tranform.js +0 -31
  83. package/dist/presets/loaders/wxss-loader.d.ts +0 -1
  84. package/dist/presets/loaders/wxss-loader.js +0 -77
  85. package/dist/presets/plugins/InjectorPlugin.d.ts +0 -7
  86. package/dist/presets/plugins/InjectorPlugin.js +0 -14
  87. package/dist/presets/prod.d.ts +0 -4
  88. package/dist/presets/prod.js +0 -80
  89. package/dist/types/index.d.ts +0 -118
  90. package/dist/types/index.js +0 -13
  91. package/dist/utils/asyncWebpack.d.ts +0 -3
  92. package/dist/utils/asyncWebpack.js +0 -38
  93. package/dist/utils/common.d.ts +0 -8
  94. package/dist/utils/common.js +0 -36
  95. package/dist/utils/const.d.ts +0 -27
  96. package/dist/utils/const.js +0 -47
  97. package/dist/utils/css.d.ts +0 -2
  98. package/dist/utils/css.js +0 -41
  99. package/dist/utils/depenedHelper.d.ts +0 -31
  100. package/dist/utils/depenedHelper.js +0 -89
  101. package/dist/utils/file.d.ts +0 -2
  102. package/dist/utils/file.js +0 -67
  103. package/dist/utils/getSuffixName.d.ts +0 -3
  104. package/dist/utils/getSuffixName.js +0 -18
  105. package/dist/utils/loader-utils.d.ts +0 -15
  106. package/dist/utils/loader-utils.js +0 -59
  107. package/dist/utils/postcssRpx2Vw.d.ts +0 -12
  108. package/dist/utils/postcssRpx2Vw.js +0 -35
  109. package/dist/utils/project.d.ts +0 -27
  110. package/dist/utils/project.js +0 -164
  111. package/dist/utils/projectConfig.d.ts +0 -1
  112. package/dist/utils/projectConfig.js +0 -20
  113. package/dist/utils/tagTransformMap.d.ts +0 -35
  114. package/dist/utils/tagTransformMap.js +0 -38
  115. package/dist/utils/utils.d.ts +0 -7
  116. package/dist/utils/utils.js +0 -50
  117. package/dist/utils/zip.d.ts +0 -28
  118. package/dist/utils/zip.js +0 -287
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tagTransformMap = {
4
- view: 'xhs-vue-view',
5
- text: 'xhs-vue-text',
6
- // block: 'span',
7
- image: 'xhs-vue-image',
8
- input: 'xhs-vue-input',
9
- icon: 'xhs-vue-icon',
10
- label: 'xhs-vue-label',
11
- radio: 'xhs-vue-radio',
12
- 'radio-group': 'xhs-vue-radio-group',
13
- checkbox: 'xhs-vue-checkbox',
14
- 'checkbox-group': 'xhs-vue-checkbox-group',
15
- switch: 'xhs-vue-switch',
16
- textarea: 'xhs-vue-textarea',
17
- button: 'xhs-vue-button',
18
- swiper: 'xhs-vue-swiper',
19
- 'swiper-item': 'xhs-vue-swiper-item',
20
- navigator: 'xhs-vue-navigator',
21
- slider: 'xhs-vue-slider',
22
- progress: 'xhs-vue-progress',
23
- 'rich-text': 'xhs-vue-rich-text',
24
- 'mf-page': 'div',
25
- 'scroll-view': 'xhs-vue-scroll-view',
26
- picker: 'xhs-vue-picker',
27
- 'picker-view': 'xhs-vue-picker-view',
28
- 'picker-view-column': 'xhs-vue-picker-view-column',
29
- form: 'xhs-vue-form',
30
- 'web-view': 'xhs-vue-web-view',
31
- video: 'xhs-vue-video',
32
- map: 'xhs-vue-map',
33
- editor: 'xhs-vue-editor',
34
- 'movable-area': 'xhs-vue-movable-area',
35
- 'movable-view': 'xhs-vue-movable-view',
36
- canvas: 'xhs-vue-canvas'
37
- };
38
- exports.default = tagTransformMap;
@@ -1,7 +0,0 @@
1
- export declare function getMd5(str: any): any;
2
- export declare function normalizePath(str: any): any;
3
- declare const _default: {
4
- hasFile: (filepath: any) => boolean;
5
- getTsconfigPath: (config: any) => string | null;
6
- };
7
- export default _default;
@@ -1,50 +0,0 @@
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.normalizePath = exports.getMd5 = void 0;
7
- // @ts-nocheck
8
- const path_1 = __importDefault(require("path"));
9
- const fs_1 = __importDefault(require("fs"));
10
- const crypto = require('crypto');
11
- function getMd5(str) {
12
- const hash = crypto.createHash('md5');
13
- hash.update(str);
14
- const md5 = hash.digest('hex');
15
- return md5;
16
- }
17
- exports.getMd5 = getMd5;
18
- function normalizePath(str) {
19
- return str.replace(/\\/g, '/');
20
- }
21
- exports.normalizePath = normalizePath;
22
- const hasFile = filepath => {
23
- try {
24
- const stat = fs_1.default.statSync(filepath);
25
- return stat.isFile();
26
- }
27
- catch (e) {
28
- return false;
29
- }
30
- };
31
- const getTsconfigPath = config => {
32
- let res = '';
33
- // 查询距离最近的 tsconfig.json
34
- if (config.projectPath) {
35
- res = path_1.default.resolve(process.cwd(), config.projectPath, 'tsconfig.json');
36
- if (hasFile(res)) {
37
- return res;
38
- }
39
- }
40
- // 查询 root 的 tsconfig.json
41
- res = path_1.default.resolve(process.cwd(), 'tsconfig.json');
42
- if (hasFile(res)) {
43
- return res;
44
- }
45
- return null;
46
- };
47
- exports.default = {
48
- hasFile,
49
- getTsconfigPath,
50
- };
@@ -1,28 +0,0 @@
1
- import type { Archiver } from 'archiver';
2
- import * as fse from 'fs-extra';
3
- interface IOptions {
4
- outputDir: string;
5
- }
6
- export declare class Zip {
7
- options: IOptions;
8
- archive: Archiver;
9
- output: fse.WriteStream;
10
- constructor(options: IOptions);
11
- initOutput(): void;
12
- finalize(): Promise<any>;
13
- }
14
- /**
15
- * 解压 zip 文件 yauzl
16
- * @param zipPath string
17
- * @param outputDir string
18
- * @param options unzipOptions
19
- */
20
- export declare function unzip(zipPath: string, outputDir: string): Promise<void>;
21
- /**
22
- * 解压 zip 文件
23
- * @param zipPath string
24
- * @param outputDir string
25
- */
26
- export declare function unzipMac(zipPath: string, outputDir: string): Promise<unknown>;
27
- export declare const genZip: (input: string, output: string, appId?: string) => Promise<void>;
28
- export {};
package/dist/utils/zip.js DELETED
@@ -1,287 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.genZip = exports.unzipMac = exports.unzip = exports.Zip = void 0;
36
- const child_process_1 = require("child_process");
37
- const fs_1 = require("fs");
38
- const fse = __importStar(require("fs-extra"));
39
- const debug = require('debug')('zip');
40
- const path = require('path');
41
- const { promisify } = require('util');
42
- const stream = require('stream');
43
- const archiver = require('archiver');
44
- const yauzl = require('yauzl');
45
- const openZip = promisify(yauzl.open);
46
- const pipeline = promisify(stream.pipeline);
47
- class Extractor {
48
- constructor(zipPath, opts) {
49
- this.zipPath = '';
50
- this.opts = null;
51
- this.zipfile = null;
52
- this.canceled = false;
53
- this.zipPath = zipPath;
54
- this.opts = opts;
55
- }
56
- extract() {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- debug('opening', this.zipPath, 'with opts', this.opts);
59
- this.zipfile = yield openZip(this.zipPath, { lazyEntries: true });
60
- this.canceled = false;
61
- return new Promise((resolve, reject) => {
62
- this.zipfile.on('error', err => {
63
- this.canceled = true;
64
- reject(err);
65
- });
66
- this.zipfile.readEntry();
67
- this.zipfile.on('close', () => {
68
- if (!this.canceled) {
69
- debug('zip extraction complete');
70
- resolve();
71
- }
72
- });
73
- this.zipfile.on('entry', (entry) => __awaiter(this, void 0, void 0, function* () {
74
- /* istanbul ignore if */
75
- if (this.canceled) {
76
- debug('skipping entry', entry.fileName, { cancelled: this.canceled });
77
- return;
78
- }
79
- debug('zipfile entry', entry.fileName);
80
- if (entry.fileName.startsWith('__MACOSX/')) {
81
- this.zipfile.readEntry();
82
- return;
83
- }
84
- const destDir = path.dirname(path.join(this.opts.dir, entry.fileName));
85
- try {
86
- yield fs_1.promises.mkdir(destDir, { recursive: true });
87
- let canonicalDestDir = '';
88
- try {
89
- canonicalDestDir = yield fs_1.promises.realpath(destDir);
90
- }
91
- catch (error) {
92
- canonicalDestDir = path.resolve(destDir);
93
- }
94
- const relativeDestDir = path.relative(this.opts.dir, canonicalDestDir);
95
- if (relativeDestDir.split(path.sep).includes('..')) {
96
- throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
97
- }
98
- yield this.extractEntry(entry);
99
- debug('finished processing', entry.fileName);
100
- this.zipfile.readEntry();
101
- }
102
- catch (err) {
103
- this.canceled = true;
104
- this.zipfile.close();
105
- reject(err);
106
- }
107
- }));
108
- });
109
- });
110
- }
111
- extractEntry(entry) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- /* istanbul ignore if */
114
- if (this.canceled) {
115
- debug('skipping entry extraction', entry.fileName, {
116
- cancelled: this.canceled
117
- });
118
- return;
119
- }
120
- if (this.opts.onEntry) {
121
- this.opts.onEntry(entry, this.zipfile);
122
- }
123
- const dest = path.join(this.opts.dir, entry.fileName);
124
- // convert external file attr int into a fs stat mode int
125
- const mode = (entry.externalFileAttributes >> 16) & 0xffff;
126
- // check if it's a symlink or dir (using stat mode constants)
127
- const IFMT = 61440;
128
- const IFDIR = 16384;
129
- const IFLNK = 40960;
130
- const symlink = (mode & IFMT) === IFLNK;
131
- let isDir = (mode & IFMT) === IFDIR;
132
- // Failsafe, borrowed from jsZip
133
- if (!isDir && entry.fileName.endsWith('/')) {
134
- isDir = true;
135
- }
136
- // check for windows weird way of specifying a directory
137
- // https://github.com/maxogden/extract-zip/issues/13#issuecomment-154494566
138
- const madeBy = entry.versionMadeBy >> 8;
139
- if (!isDir)
140
- isDir = madeBy === 0 && entry.externalFileAttributes === 16;
141
- debug('extracting entry', {
142
- filename: entry.fileName,
143
- isDir,
144
- isSymlink: symlink
145
- });
146
- const procMode = this.getExtractedMode(mode, isDir) & 0o777;
147
- // always ensure folders are created
148
- const destDir = isDir ? dest : path.dirname(dest);
149
- const mkdirOptions = { recursive: true };
150
- if (isDir) {
151
- mkdirOptions.mode = procMode;
152
- }
153
- debug('mkdir', Object.assign({ dir: destDir }, mkdirOptions));
154
- yield fs_1.promises.mkdir(destDir, mkdirOptions);
155
- if (isDir)
156
- return;
157
- debug('opening read stream', dest);
158
- const readStream = yield promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);
159
- if (symlink) {
160
- // const link = await getStream(readStream)
161
- // debug('creating symlink', link, dest)
162
- // await fs.symlink(link, dest)
163
- }
164
- else {
165
- yield pipeline(readStream, (0, fs_1.createWriteStream)(dest, { mode: procMode }));
166
- }
167
- });
168
- }
169
- getExtractedMode(entryMode, isDir) {
170
- let mode = entryMode;
171
- // Set defaults, if necessary
172
- if (mode === 0) {
173
- if (isDir) {
174
- if (this.opts.defaultDirMode) {
175
- mode = parseInt(this.opts.defaultDirMode, 10);
176
- }
177
- if (!mode) {
178
- mode = 0o755;
179
- }
180
- }
181
- else {
182
- if (this.opts.defaultFileMode) {
183
- mode = parseInt(this.opts.defaultFileMode, 10);
184
- }
185
- if (!mode) {
186
- mode = 0o644;
187
- }
188
- }
189
- }
190
- return mode;
191
- }
192
- }
193
- class Zip {
194
- constructor(options) {
195
- this.options = options;
196
- this.archive = archiver('zip', {
197
- zlib: { level: 9 } // Sets the compression level.
198
- });
199
- this.initOutput();
200
- }
201
- initOutput() {
202
- const { outputDir } = this.options;
203
- this.output = fse.createWriteStream(outputDir);
204
- this.archive.pipe(this.output);
205
- }
206
- finalize() {
207
- return __awaiter(this, void 0, void 0, function* () {
208
- return this.archive.finalize();
209
- });
210
- }
211
- }
212
- exports.Zip = Zip;
213
- /**
214
- * 解压 zip 文件 yauzl
215
- * @param zipPath string
216
- * @param outputDir string
217
- * @param options unzipOptions
218
- */
219
- function unzip(zipPath, outputDir) {
220
- return __awaiter(this, void 0, void 0, function* () {
221
- debug('creating target directory', outputDir);
222
- if (!path.isAbsolute(outputDir)) {
223
- throw new Error('Target directory is expected to be absolute');
224
- }
225
- yield fs_1.promises.mkdir(outputDir, { recursive: true });
226
- const _outputDir = yield fs_1.promises.realpath(outputDir);
227
- return new Extractor(zipPath, {
228
- dir: _outputDir
229
- }).extract();
230
- });
231
- }
232
- exports.unzip = unzip;
233
- /**
234
- * 解压 zip 文件
235
- * @param zipPath string
236
- * @param outputDir string
237
- */
238
- function unzipMac(zipPath, outputDir) {
239
- return __awaiter(this, void 0, void 0, function* () {
240
- return new Promise((resolve, reject) => {
241
- const proc = (0, child_process_1.spawn)('/usr/bin/unzip', [zipPath, '-d', outputDir]);
242
- const output = '';
243
- proc.on('error', err => {
244
- reject(err);
245
- });
246
- proc.on('exit', (code) => {
247
- if (code > 0) {
248
- reject(new Error(`Exited with code ${code}`));
249
- }
250
- else {
251
- resolve(output);
252
- }
253
- });
254
- proc.stderr.on('data', chunk => {
255
- console.error(chunk.toString());
256
- });
257
- proc.stdout.on('data', chunk => {
258
- // console.log(chunk.toString());
259
- });
260
- });
261
- });
262
- }
263
- exports.unzipMac = unzipMac;
264
- const genZip = (input, output, appId) => __awaiter(void 0, void 0, void 0, function* () {
265
- return new Promise((resolve, reject) => {
266
- const outputStream = (0, fs_1.createWriteStream)(output);
267
- const archive = archiver('zip', {
268
- zlib: { level: 9 } // Sets the compression level.
269
- });
270
- outputStream.on('close', () => {
271
- resolve();
272
- });
273
- archive.on('error', error => {
274
- console.error('archive error:', error);
275
- reject(error);
276
- });
277
- archive.pipe(outputStream);
278
- if (appId) {
279
- archive.directory(input, appId);
280
- }
281
- else {
282
- archive.directory(input, './');
283
- }
284
- archive.finalize();
285
- });
286
- });
287
- exports.genZip = genZip;