pake-cli 0.0.1-beta.1 → 0.0.1-beta.11

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 (66) hide show
  1. package/.github/FUNDING.yml +2 -0
  2. package/.vscode/settings.json +7 -0
  3. package/bin/builders/BuilderFactory.ts +12 -0
  4. package/bin/builders/LinuxBuilder.ts +0 -0
  5. package/bin/builders/MacBuilder.ts +66 -0
  6. package/bin/builders/WinBulider.ts +0 -0
  7. package/bin/builders/base.ts +7 -0
  8. package/bin/builders/common.ts +6 -0
  9. package/bin/cli.ts +29 -0
  10. package/bin/defaults.ts +12 -0
  11. package/bin/helpers/rust.ts +21 -0
  12. package/bin/helpers/tauriConfig.ts +8 -0
  13. package/bin/options/icon.ts +99 -0
  14. package/bin/options/index.ts +24 -0
  15. package/bin/options/title.ts +14 -0
  16. package/bin/types.ts +29 -0
  17. package/{dist/utils/platform.js → bin/utils/platform.ts} +2 -1
  18. package/bin/utils/shell.ts +12 -0
  19. package/bin/utils/url.ts +21 -0
  20. package/bin/utils/validate.ts +18 -0
  21. package/cli.js +2 -0
  22. package/dist/cli.js +381 -16
  23. package/package.json +13 -13
  24. package/rollup.config.js +24 -0
  25. package/dist/builders/BuilderFactory.js +0 -11
  26. package/dist/builders/BuilderFactory.js.map +0 -1
  27. package/dist/builders/LinuxBuilder.js +0 -2
  28. package/dist/builders/LinuxBuilder.js.map +0 -1
  29. package/dist/builders/MacBuilder.js +0 -74
  30. package/dist/builders/MacBuilder.js.map +0 -1
  31. package/dist/builders/WinBulider.js +0 -2
  32. package/dist/builders/WinBulider.js.map +0 -1
  33. package/dist/builders/base.js +0 -2
  34. package/dist/builders/base.js.map +0 -1
  35. package/dist/builders/common.js +0 -38
  36. package/dist/builders/common.js.map +0 -1
  37. package/dist/cli.js.map +0 -1
  38. package/dist/defaults.js +0 -10
  39. package/dist/defaults.js.map +0 -1
  40. package/dist/helpers/dir.js +0 -9
  41. package/dist/helpers/dir.js.map +0 -1
  42. package/dist/helpers/path.js +0 -2
  43. package/dist/helpers/path.js.map +0 -1
  44. package/dist/helpers/prepareCheck.js +0 -53
  45. package/dist/helpers/prepareCheck.js.map +0 -1
  46. package/dist/helpers/rust.js +0 -31
  47. package/dist/helpers/rust.js.map +0 -1
  48. package/dist/helpers/tauriConfig.js +0 -8
  49. package/dist/helpers/tauriConfig.js.map +0 -1
  50. package/dist/options/icon.js +0 -111
  51. package/dist/options/icon.js.map +0 -1
  52. package/dist/options/index.js +0 -27
  53. package/dist/options/index.js.map +0 -1
  54. package/dist/options/title.js +0 -25
  55. package/dist/options/title.js.map +0 -1
  56. package/dist/pake.js +0 -43
  57. package/dist/pake.js.map +0 -1
  58. package/dist/types.js +0 -2
  59. package/dist/types.js.map +0 -1
  60. package/dist/utils/platform.js.map +0 -1
  61. package/dist/utils/shell.js +0 -14
  62. package/dist/utils/shell.js.map +0 -1
  63. package/dist/utils/url.js +0 -20
  64. package/dist/utils/url.js.map +0 -1
  65. package/dist/utils/validate.js +0 -18
  66. package/dist/utils/validate.js.map +0 -1
package/dist/cli.js CHANGED
@@ -1,19 +1,385 @@
1
- #!/usr/bin/env node
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1
+ import * as Commander from 'commander';
2
+ import { program } from 'commander';
3
+ import url from 'url';
4
+ import isurl from 'is-url';
5
+ import crypto from 'crypto';
6
+ import axios from 'axios';
7
+ import { fileTypeFromBuffer } from 'file-type';
8
+ import { dir } from 'tmp-promise';
9
+ import path from 'path';
10
+ import pageIcon from 'page-icon';
11
+ import png2icons from 'png2icons';
12
+ import ICO from 'icojs';
13
+ import fs from 'fs/promises';
14
+ import prompts from 'prompts';
15
+ import ora from 'ora';
16
+ import shelljs from 'shelljs';
17
+ import appRootPath from 'app-root-path';
18
+
19
+ /******************************************************************************
20
+ Copyright (c) Microsoft Corporation.
21
+
22
+ Permission to use, copy, modify, and/or distribute this software for any
23
+ purpose with or without fee is hereby granted.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
26
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
27
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
28
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
29
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
30
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
31
+ PERFORMANCE OF THIS SOFTWARE.
32
+ ***************************************************************************** */
33
+
34
+ function __awaiter(thisArg, _arguments, P, generator) {
35
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
36
+ return new (P || (P = Promise))(function (resolve, reject) {
37
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
38
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
39
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
40
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
41
+ });
42
+ }
43
+
44
+ const DEFAULT_PAKE_OPTIONS = {
45
+ icon: '',
46
+ height: 800,
47
+ width: 1280,
48
+ fullscreen: false,
49
+ resizable: true,
50
+ transparent: false,
51
+ };
52
+
53
+ function appendProtocol(inputUrl) {
54
+ const parsed = url.parse(inputUrl);
55
+ if (!parsed.protocol) {
56
+ const urlWithProtocol = `https://${inputUrl}`;
57
+ return urlWithProtocol;
58
+ }
59
+ return inputUrl;
60
+ }
61
+ function normalizeUrl(urlToNormalize) {
62
+ const urlWithProtocol = appendProtocol(urlToNormalize);
63
+ if (isurl(urlWithProtocol)) {
64
+ return urlWithProtocol;
65
+ }
66
+ else {
67
+ throw new Error(`Your url "${urlWithProtocol}" is invalid`);
68
+ }
69
+ }
70
+
71
+ function validateNumberInput(value) {
72
+ const parsedValue = Number(value);
73
+ if (isNaN(parsedValue)) {
74
+ throw new Commander.InvalidArgumentError('Not a number.');
75
+ }
76
+ return parsedValue;
77
+ }
78
+ function validateUrlInput(url) {
79
+ try {
80
+ return normalizeUrl(url);
81
+ }
82
+ catch (error) {
83
+ throw new Commander.InvalidArgumentError(error.message);
84
+ }
85
+ }
86
+
87
+ function getIdentifier(name, url) {
88
+ const hash = crypto.createHash('md5');
89
+ hash.update(url);
90
+ const postFixHash = hash.digest('hex').substring(0, 6);
91
+ return `pake-${postFixHash}`;
92
+ }
93
+
94
+ function handleIcon(options, url) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ console.log(options.icon);
97
+ if (options.icon) {
98
+ if (options.icon.startsWith('http')) {
99
+ return downloadIcon(options.icon);
100
+ }
101
+ else {
102
+ return path.resolve(options.icon);
103
+ }
104
+ }
105
+ if (!options.icon) {
106
+ return inferIcon(options.name, url);
107
+ }
108
+ });
109
+ }
110
+ function inferIcon(name, url) {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ let icon = yield getIconFromMacosIcons(name);
113
+ if (!icon) {
114
+ icon = yield getIconFromPageUrl(url);
115
+ }
116
+ return icon;
117
+ });
118
+ }
119
+ function getIconFromPageUrl(url) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ const icon = yield pageIcon(url);
122
+ console.log(icon);
123
+ if (icon.ext === '.ico') {
124
+ const a = yield ICO.parse(icon.data);
125
+ icon.data = Buffer.from(a[0].buffer);
126
+ }
127
+ const iconDir = (yield dir()).path;
128
+ const iconPath = path.join(iconDir, `/icon.icns`);
129
+ const out = png2icons.createICNS(icon.data, png2icons.BILINEAR, 0);
130
+ yield fs.writeFile(iconPath, out);
131
+ return iconPath;
132
+ });
133
+ }
134
+ function getIconFromMacosIcons(name) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ const data = {
137
+ query: name,
138
+ filters: 'approved:true',
139
+ hitsPerPage: 10,
140
+ page: 1,
141
+ };
142
+ const res = yield axios.post('https://p1txh7zfb3-2.algolianet.com/1/indexes/macOSicons/query?x-algolia-agent=Algolia%20for%20JavaScript%20(4.13.1)%3B%20Browser', data, {
143
+ headers: {
144
+ 'x-algolia-api-key': '0ba04276e457028f3e11e38696eab32c',
145
+ 'x-algolia-application-id': 'P1TXH7ZFB3',
146
+ },
147
+ });
148
+ if (!res.data.hits.length) {
149
+ return '';
150
+ }
151
+ else {
152
+ return downloadIcon(res.data.hits[0].icnsUrl);
153
+ }
154
+ });
155
+ }
156
+ function downloadIcon(iconUrl) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ let iconResponse;
159
+ try {
160
+ iconResponse = yield axios.get(iconUrl, {
161
+ responseType: 'arraybuffer',
162
+ });
163
+ }
164
+ catch (error) {
165
+ if (error.response && error.response.status === 404) {
166
+ return null;
167
+ }
168
+ throw error;
169
+ }
170
+ const iconData = yield iconResponse.data;
171
+ if (!iconData) {
172
+ return null;
173
+ }
174
+ const fileDetails = yield fileTypeFromBuffer(iconData);
175
+ if (!fileDetails) {
176
+ return null;
177
+ }
178
+ const { path } = yield dir();
179
+ const iconPath = `${path}/icon.${fileDetails.ext}`;
180
+ yield fs.writeFile(iconPath, iconData);
181
+ return iconPath;
182
+ });
183
+ }
184
+
185
+ const USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36';
186
+ function getTitleByURL(url) {
187
+ var _a, _b, _c;
188
+ return __awaiter(this, void 0, void 0, function* () {
189
+ const { data } = yield axios.get(url, {
190
+ headers: {
191
+ // Fake user agent for pages like http://messenger.com
192
+ 'User-Agent': USER_AGENT,
193
+ },
194
+ });
195
+ const title = (_c = (_b = (_a = /<\s*title.*?>(?<title>.+?)<\s*\/title\s*?>/i.exec(data)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : 'Webapp';
196
+ return title;
9
197
  });
198
+ }
199
+
200
+ function handleOptions(options, url) {
201
+ return __awaiter(this, void 0, void 0, function* () {
202
+ const appOptions = Object.assign(Object.assign({}, options), { identifier: '' });
203
+ if (!appOptions.title) {
204
+ appOptions.title = yield getTitleByURL(url);
205
+ }
206
+ if (!appOptions.name) {
207
+ appOptions.name = appOptions.title;
208
+ }
209
+ appOptions.identifier = getIdentifier(appOptions.name, url);
210
+ appOptions.icon = yield handleIcon(appOptions, url);
211
+ return appOptions;
212
+ });
213
+ }
214
+
215
+ const IS_MAC = process.platform === 'darwin';
216
+ process.platform === 'win32';
217
+ process.platform === 'linux';
218
+
219
+ function shellExec(command) {
220
+ return new Promise((resolve, reject) => {
221
+ shelljs.exec(command, { async: true, silent: false }, (code) => {
222
+ if (code === 0) {
223
+ resolve(0);
224
+ }
225
+ else {
226
+ reject(new Error(`${code}`));
227
+ }
228
+ });
229
+ });
230
+ }
231
+
232
+ const InstallRustScript = "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
233
+ function installRust() {
234
+ return __awaiter(this, void 0, void 0, function* () {
235
+ const spinner = ora('Downloading Rust').start();
236
+ try {
237
+ yield shellExec(InstallRustScript);
238
+ spinner.succeed();
239
+ }
240
+ catch (error) {
241
+ console.error('install rust return code', error.message);
242
+ spinner.fail();
243
+ process.exit(1);
244
+ }
245
+ });
246
+ }
247
+ function checkRustInstalled() {
248
+ return shelljs.exec('rustc --version', { silent: true }).code === 0;
249
+ }
250
+
251
+ var tauri = {
252
+ windows: [
253
+ {
254
+ url: "https://baidu.com",
255
+ transparent: false,
256
+ fullscreen: false,
257
+ width: 1280,
258
+ height: 800,
259
+ resizable: true,
260
+ title: "百度一下,你就知道"
261
+ }
262
+ ],
263
+ allowlist: {
264
+ all: true
265
+ },
266
+ bundle: {
267
+ icon: [
268
+ "/var/folders/vd/8qqrr2yd6gbf23bgx5vhdzrm0000gn/T/tmp-91408-NUAYXSkVg43n/icon.icns"
269
+ ],
270
+ active: true,
271
+ category: "DeveloperTool",
272
+ copyright: "",
273
+ deb: {
274
+ depends: [
275
+ ]
276
+ },
277
+ externalBin: [
278
+ ],
279
+ identifier: "pake-bb6e08",
280
+ longDescription: "",
281
+ macOS: {
282
+ entitlements: null,
283
+ exceptionDomain: "",
284
+ frameworks: [
285
+ ],
286
+ providerShortName: null,
287
+ signingIdentity: null
288
+ },
289
+ resources: [
290
+ ],
291
+ shortDescription: "",
292
+ targets: "all",
293
+ windows: {
294
+ certificateThumbprint: null,
295
+ digestAlgorithm: "sha256",
296
+ timestampUrl: ""
297
+ }
298
+ },
299
+ security: {
300
+ csp: null
301
+ },
302
+ updater: {
303
+ active: false
304
+ }
10
305
  };
11
- import { program } from 'commander';
12
- import { DEFAULT_PAKE_OPTIONS } from './defaults.js';
13
- import { validateNumberInput, validateUrlInput } from './utils/validate.js';
14
- import handleInputOptions from './options/index.js';
15
- import BuilderFactory from './builders/BuilderFactory.js';
16
- program.version('0.0.1').description('A cli application can build website to app, driven by tauri');
306
+ var build = {
307
+ devPath: "../dist",
308
+ distDir: "../dist",
309
+ beforeBuildCommand: "",
310
+ beforeDevCommand: ""
311
+ };
312
+ var tauriConf = {
313
+ "package": {
314
+ productName: "baidu",
315
+ version: "0.2.0"
316
+ },
317
+ tauri: tauri,
318
+ build: build
319
+ };
320
+
321
+ class MacBuilder {
322
+ prepare() {
323
+ return __awaiter(this, void 0, void 0, function* () {
324
+ if (checkRustInstalled()) {
325
+ console.log('Rust has been installed');
326
+ return;
327
+ }
328
+ console.warn('Rust is not installed, show prompt');
329
+ const res = yield prompts({
330
+ type: 'confirm',
331
+ message: 'Detect you have not installed Rust, install it now?',
332
+ name: 'value',
333
+ });
334
+ if (res.value) {
335
+ // TODO 国内有可能会超时
336
+ yield installRust();
337
+ }
338
+ else {
339
+ console.error('Error: Pake need Rust to package your webapp!!!');
340
+ process.exit(2);
341
+ }
342
+ });
343
+ }
344
+ build(url, options) {
345
+ return __awaiter(this, void 0, void 0, function* () {
346
+ console.log('PakeAppOptions', options);
347
+ const { width, height, fullscreen, transparent, title, resizable, identifier, name } = options;
348
+ const tauriConfWindowOptions = {
349
+ width,
350
+ height,
351
+ fullscreen,
352
+ transparent,
353
+ title,
354
+ resizable,
355
+ };
356
+ Object.assign(tauriConf.tauri.windows[0], Object.assign({ url }, tauriConfWindowOptions));
357
+ tauriConf.package.productName = name;
358
+ tauriConf.tauri.bundle.identifier = identifier;
359
+ tauriConf.tauri.bundle.icon = [options.icon];
360
+ const { path: dirPath } = yield dir();
361
+ const configJsonPath = `${dirPath}/config.json`;
362
+ yield fs.writeFile(configJsonPath, Buffer.from(JSON.stringify(tauriConf), 'utf-8'));
363
+ yield shellExec(`${path.join(appRootPath.path, '/node_modules/@tauri-apps/cli/tauri.js')} build --config ${configJsonPath} --target universal-apple-darwin`);
364
+ const dmgName = `${name}_${'0.2.0'}_universal.dmg`;
365
+ yield fs.copyFile(this.getBuildedAppPath(dmgName), path.resolve(dmgName));
366
+ });
367
+ }
368
+ getBuildedAppPath(dmgName) {
369
+ return path.join(appRootPath.path, 'src-tauri/target/universal-apple-darwin/release/bundle/dmg', dmgName);
370
+ }
371
+ }
372
+
373
+ class BuilderFactory {
374
+ static create() {
375
+ if (IS_MAC) {
376
+ return new MacBuilder();
377
+ }
378
+ throw new Error('The current system does not support');
379
+ }
380
+ }
381
+
382
+ program.version('0.0.1').description('A cli application can build app from website, driven by tauri');
17
383
  program
18
384
  .argument('<url>', 'the web url you want to package', validateUrlInput)
19
385
  .option('--name <string>', 'application name')
@@ -27,8 +393,7 @@ program
27
393
  .action((url, options) => __awaiter(void 0, void 0, void 0, function* () {
28
394
  const builder = BuilderFactory.create();
29
395
  yield builder.prepare();
30
- const appOptions = yield handleInputOptions(options, url);
396
+ const appOptions = yield handleOptions(options, url);
31
397
  builder.build(url, appOptions);
32
398
  }));
33
399
  program.parse();
34
- //# sourceMappingURL=cli.js.map
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pake-cli",
3
- "version": "0.0.1-beta.1",
3
+ "version": "0.0.1-beta.11",
4
4
  "description": "用 Rust 来打包你的 App,底层使用 Tauri,当前支持微信读书、Flomo、Vercel",
5
5
  "bin": {
6
- "pake": "dist/cli.js"
6
+ "pake": "./cli.js"
7
7
  },
8
8
  "repository": {
9
9
  "type": "git",
@@ -13,20 +13,13 @@
13
13
  "name": "Tw93",
14
14
  "email": "tw93@qq.com"
15
15
  },
16
- "files": [
17
- "dist",
18
- "src-tauri",
19
- "README_EN.md",
20
- "README.md",
21
- "tsconfig.json"
22
- ],
23
16
  "scripts": {
24
17
  "start": "npm run dev",
25
18
  "dev": "npm run tauri dev",
26
19
  "build": "npm run tauri build -- --target universal-apple-darwin",
27
20
  "tauri": "tauri",
28
- "cli": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")",
29
- "cli:build": "tsc && tsc-alias"
21
+ "cli": "rollup -c rollup.config.js --watch",
22
+ "cli:build": "rollup -c rollup.config.js"
30
23
  },
31
24
  "type": "module",
32
25
  "exports": "./dist/pake.js",
@@ -35,6 +28,7 @@
35
28
  "@tauri-apps/api": "^1.0.2",
36
29
  "app-root-path": "^3.1.0",
37
30
  "axios": "^1.1.3",
31
+ "commander": "^9.4.1",
38
32
  "file-type": "^18.0.0",
39
33
  "icojs": "^0.17.0",
40
34
  "is-url": "^1.2.4",
@@ -42,19 +36,25 @@
42
36
  "page-icon": "^0.4.0",
43
37
  "png2icons": "^2.0.1",
44
38
  "prompts": "^2.4.2",
39
+ "shelljs": "^0.8.5",
45
40
  "tmp-promise": "^3.0.3"
46
41
  },
47
42
  "devDependencies": {
43
+ "@rollup/plugin-alias": "^4.0.2",
44
+ "@rollup/plugin-commonjs": "^23.0.2",
45
+ "@rollup/plugin-json": "^5.0.1",
46
+ "@rollup/plugin-typescript": "^9.0.2",
48
47
  "@tauri-apps/cli": "^1.0.2",
49
48
  "@types/is-url": "^1.2.30",
50
49
  "@types/page-icon": "^0.3.4",
51
50
  "@types/prompts": "^2.4.1",
52
51
  "@types/shelljs": "^0.8.11",
53
52
  "@types/tmp": "^0.2.3",
54
- "commander": "^9.4.1",
55
53
  "concurrently": "^7.5.0",
56
- "shelljs": "^0.8.5",
54
+ "rollup": "^3.3.0",
55
+ "rollup-plugin-typescript2": "^0.34.1",
57
56
  "tsc-alias": "^1.7.1",
57
+ "tslib": "^2.4.1",
58
58
  "typescript": "^4.8.4"
59
59
  }
60
60
  }
@@ -0,0 +1,24 @@
1
+ import path from 'path';
2
+ import appRootPath from 'app-root-path';
3
+ import typescript from '@rollup/plugin-typescript';
4
+ import alias from '@rollup/plugin-alias';
5
+ import commonjs from '@rollup/plugin-commonjs';
6
+ import json from '@rollup/plugin-json';
7
+
8
+ export default {
9
+ input: 'bin/cli.ts',
10
+ output: {
11
+ file: 'dist/cli.js',
12
+ format: 'es'
13
+ },
14
+ plugins: [
15
+ typescript({
16
+ sourceMap: false,
17
+ }),
18
+ json(),
19
+ commonjs(),
20
+ alias({
21
+ entries: [{ find: '@', replacement: path.join(appRootPath.path, 'bin') }],
22
+ }),
23
+ ],
24
+ };
@@ -1,11 +0,0 @@
1
- import { IS_MAC } from '../utils/platform.js';
2
- import MacBuilder from './MacBuilder.js';
3
- export default class BuilderFactory {
4
- static create() {
5
- if (IS_MAC) {
6
- return new MacBuilder();
7
- }
8
- throw new Error('The current system does not support');
9
- }
10
- }
11
- //# sourceMappingURL=BuilderFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuilderFactory.js","sourceRoot":"","sources":["../../bin/builders/BuilderFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,MAAM,CAAC,MAAM;QACX,IAAI,MAAM,EAAE;YACV,OAAO,IAAI,UAAU,EAAE,CAAC;SACzB;QACD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;CACF"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=LinuxBuilder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LinuxBuilder.js","sourceRoot":"","sources":["../../bin/builders/LinuxBuilder.ts"],"names":[],"mappings":""}
@@ -1,74 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import fs from 'fs/promises';
11
- import path from 'path';
12
- import prompts from 'prompts';
13
- import { checkRustInstalled, installRust } from '../helpers/rust.js';
14
- import appRootPath from 'app-root-path';
15
- import { shellExec } from '../utils/shell.js';
16
- export default class MacBuilder {
17
- prepare() {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- if (checkRustInstalled()) {
20
- console.log('Rust has been installed');
21
- return;
22
- }
23
- console.warn('Rust is not installed, show prompt');
24
- const res = yield prompts({
25
- type: 'confirm',
26
- message: 'Detect you have not installed Rust, install it now?',
27
- name: 'value',
28
- });
29
- if (res.value) {
30
- // TODO 国内有可能会超时
31
- yield installRust();
32
- }
33
- else {
34
- console.error('Error: Pake need Rust to package your webapp!!!');
35
- process.exit(2);
36
- }
37
- });
38
- }
39
- build(url, options) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- console.log('PakeAppOptions', options);
42
- const tauriConfPath = path.join(appRootPath.path, 'src-tauri/tauri.conf.json');
43
- const tauriConfString = yield fs.readFile(tauriConfPath, 'utf-8');
44
- try {
45
- const tauriConf = JSON.parse(tauriConfString);
46
- const { width, height, fullscreen, transparent, title, resizable, identifier, name } = options;
47
- const tauriConfWindowOptions = {
48
- width,
49
- height,
50
- fullscreen,
51
- transparent,
52
- title,
53
- resizable,
54
- };
55
- Object.assign(tauriConf.tauri.windows[0], Object.assign({ url }, tauriConfWindowOptions));
56
- tauriConf.package.productName = name;
57
- tauriConf.tauri.bundle.identifier = identifier;
58
- tauriConf.tauri.bundle.icon = [options.icon];
59
- yield fs.writeFile(tauriConfPath, JSON.stringify(tauriConf, null, 2));
60
- const code = yield shellExec(`${path.join(appRootPath.path, '/node_modules/.bin/tauri')} build --config ${tauriConfPath} --target universal-apple-darwin`);
61
- const dmgName = `${name}_${'0.2.0'}_universal.dmg`;
62
- yield fs.copyFile(this.getBuildedAppPath(dmgName), path.resolve(dmgName));
63
- }
64
- catch (error) {
65
- console.error('handle tauri.conf.json error', error);
66
- return;
67
- }
68
- });
69
- }
70
- getBuildedAppPath(dmgName) {
71
- return path.join(appRootPath.path, 'src-tauri/target/universal-apple-darwin/release/bundle/dmg', dmgName);
72
- }
73
- }
74
- //# sourceMappingURL=MacBuilder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MacBuilder.js","sourceRoot":"","sources":["../../bin/builders/MacBuilder.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,WAAW,EA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bin/builders/WinBulider.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../bin/builders/base.ts"],"names":[],"mappings":""}
@@ -1,38 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import path from 'path';
11
- import { checkRustInstalled, installRust } from '../helpers/rust.js';
12
- import appRootPath from 'app-root-path';
13
- import prompts from 'prompts';
14
- export function prepareCheck() {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- if (checkRustInstalled()) {
17
- console.log('Rust has been installed');
18
- return;
19
- }
20
- console.warn('Rust is not installed, show prompt');
21
- const res = yield prompts({
22
- type: 'confirm',
23
- message: 'Detect you have not installed Rust, install it now?',
24
- name: 'value',
25
- });
26
- if (res.value) {
27
- yield installRust();
28
- }
29
- else {
30
- console.error('Error: Pake need Rust to package your webapp!!!');
31
- process.exit(2);
32
- }
33
- });
34
- }
35
- export function getBuildedAppPath(name, version) {
36
- return path.join(appRootPath.path, 'src-tauri/target/universal-apple-darwin/release/bundle/dmg', `${name}_${version}_universal.dmg`);
37
- }
38
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../bin/builders/common.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM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