pake-cli 0.0.1-beta.7 → 0.0.1-beta.9

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.
@@ -6,6 +6,8 @@ import { PakeAppOptions } from '@/types.js';
6
6
  import { IBuilder } from './base.js';
7
7
  import appRootPath from 'app-root-path';
8
8
  import { shellExec } from '@/utils/shell.js';
9
+ import tauriConf from '../../src-tauri/tauri.conf.json';
10
+ import { dir } from 'tmp-promise';
9
11
 
10
12
  export default class MacBuilder implements IBuilder {
11
13
  async prepare() {
@@ -32,35 +34,30 @@ export default class MacBuilder implements IBuilder {
32
34
 
33
35
  async build(url: string, options: PakeAppOptions) {
34
36
  console.log('PakeAppOptions', options);
35
- const tauriConfPath = path.join(appRootPath.path, 'src-tauri/tauri.conf.json');
36
- const tauriConfString = await fs.readFile(tauriConfPath, 'utf-8');
37
- try {
38
- const tauriConf = JSON.parse(tauriConfString);
39
37
 
40
- const { width, height, fullscreen, transparent, title, resizable, identifier, name } = options;
38
+ const { width, height, fullscreen, transparent, title, resizable, identifier, name } = options;
41
39
 
42
- const tauriConfWindowOptions = {
43
- width,
44
- height,
45
- fullscreen,
46
- transparent,
47
- title,
48
- resizable,
49
- };
40
+ const tauriConfWindowOptions = {
41
+ width,
42
+ height,
43
+ fullscreen,
44
+ transparent,
45
+ title,
46
+ resizable,
47
+ };
50
48
 
51
- Object.assign(tauriConf.tauri.windows[0], { url, ...tauriConfWindowOptions });
52
- tauriConf.package.productName = name;
53
- tauriConf.tauri.bundle.identifier = identifier;
54
- tauriConf.tauri.bundle.icon = [options.icon];
49
+ Object.assign(tauriConf.tauri.windows[0], { url, ...tauriConfWindowOptions });
50
+ tauriConf.package.productName = name;
51
+ tauriConf.tauri.bundle.identifier = identifier;
52
+ tauriConf.tauri.bundle.icon = [options.icon];
55
53
 
56
- await fs.writeFile(tauriConfPath, JSON.stringify(tauriConf, null, 2));
57
- const code = await shellExec(`${path.join(appRootPath.path, '/node_modules/.bin/tauri')} build --config ${tauriConfPath} --target universal-apple-darwin`);
58
- const dmgName = `${name}_${'0.2.0'}_universal.dmg`;
59
- await fs.copyFile(this.getBuildedAppPath(dmgName), path.resolve(dmgName));
60
- } catch (error) {
61
- console.error('handle tauri.conf.json error', error);
62
- return;
63
- }
54
+ const { path: dirPath } = await dir();
55
+ const configJsonPath = `${dirPath}/config.json`;
56
+ await fs.writeFile(configJsonPath, Buffer.from(JSON.stringify(tauriConf), 'utf-8'));
57
+
58
+ const code = await shellExec(`npx tauri build --config ${configJsonPath} --target universal-apple-darwin`);
59
+ const dmgName = `${name}_${'0.2.0'}_universal.dmg`;
60
+ await fs.copyFile(this.getBuildedAppPath(dmgName), path.resolve(dmgName));
64
61
  }
65
62
 
66
63
  getBuildedAppPath(dmgName: string) {
@@ -1,28 +1,5 @@
1
1
  import path from 'path';
2
- import { checkRustInstalled, installRust } from '@/helpers/rust.js';
3
2
  import appRootPath from 'app-root-path';
4
- import prompts from 'prompts';
5
-
6
- export async function prepareCheck() {
7
- if (checkRustInstalled()) {
8
- console.log('Rust has been installed');
9
- return;
10
- }
11
-
12
- console.warn('Rust is not installed, show prompt');
13
- const res = await prompts({
14
- type: 'confirm',
15
- message: 'Detect you have not installed Rust, install it now?',
16
- name: 'value',
17
- });
18
-
19
- if (res.value) {
20
- await installRust();
21
- } else {
22
- console.error('Error: Pake need Rust to package your webapp!!!');
23
- process.exit(2);
24
- }
25
- }
26
3
 
27
4
  export function getBuildedAppPath(name: string, version: string) {
28
5
  return path.join(appRootPath.path, 'src-tauri/target/universal-apple-darwin/release/bundle/dmg', `${name}_${version}_universal.dmg`);
package/bin/cli.ts CHANGED
@@ -5,7 +5,7 @@ import { validateNumberInput, validateUrlInput } from './utils/validate.js';
5
5
  import handleInputOptions from './options/index.js';
6
6
  import BuilderFactory from './builders/BuilderFactory.js';
7
7
 
8
- program.version('0.0.1').description('A cli application can build website to app, driven by tauri');
8
+ program.version('0.0.1').description('A cli application can build app from website, driven by tauri');
9
9
 
10
10
  program
11
11
  .argument('<url>', 'the web url you want to package', validateUrlInput)
package/dist/cli.js CHANGED
@@ -248,6 +248,76 @@ function checkRustInstalled() {
248
248
  return shelljs.exec('rustc --version', { silent: true }).code === 0;
249
249
  }
250
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
+ }
305
+ };
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
+
251
321
  class MacBuilder {
252
322
  prepare() {
253
323
  return __awaiter(this, void 0, void 0, function* () {
@@ -274,32 +344,25 @@ class MacBuilder {
274
344
  build(url, options) {
275
345
  return __awaiter(this, void 0, void 0, function* () {
276
346
  console.log('PakeAppOptions', options);
277
- const tauriConfPath = path.join(appRootPath.path, 'src-tauri/tauri.conf.json');
278
- const tauriConfString = yield fs.readFile(tauriConfPath, 'utf-8');
279
- try {
280
- const tauriConf = JSON.parse(tauriConfString);
281
- const { width, height, fullscreen, transparent, title, resizable, identifier, name } = options;
282
- const tauriConfWindowOptions = {
283
- width,
284
- height,
285
- fullscreen,
286
- transparent,
287
- title,
288
- resizable,
289
- };
290
- Object.assign(tauriConf.tauri.windows[0], Object.assign({ url }, tauriConfWindowOptions));
291
- tauriConf.package.productName = name;
292
- tauriConf.tauri.bundle.identifier = identifier;
293
- tauriConf.tauri.bundle.icon = [options.icon];
294
- yield fs.writeFile(tauriConfPath, JSON.stringify(tauriConf, null, 2));
295
- const code = yield shellExec(`${path.join(appRootPath.path, '/node_modules/.bin/tauri')} build --config ${tauriConfPath} --target universal-apple-darwin`);
296
- const dmgName = `${name}_${'0.2.0'}_universal.dmg`;
297
- yield fs.copyFile(this.getBuildedAppPath(dmgName), path.resolve(dmgName));
298
- }
299
- catch (error) {
300
- console.error('handle tauri.conf.json error', error);
301
- return;
302
- }
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/.bin/tauri')} 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));
303
366
  });
304
367
  }
305
368
  getBuildedAppPath(dmgName) {
@@ -316,7 +379,7 @@ class BuilderFactory {
316
379
  }
317
380
  }
318
381
 
319
- program.version('0.0.1').description('A cli application can build website to app, driven by tauri');
382
+ program.version('0.0.1').description('A cli application can build app from website, driven by tauri');
320
383
  program
321
384
  .argument('<url>', 'the web url you want to package', validateUrlInput)
322
385
  .option('--name <string>', 'application name')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pake-cli",
3
- "version": "0.0.1-beta.7",
3
+ "version": "0.0.1-beta.9",
4
4
  "description": "用 Rust 来打包你的 App,底层使用 Tauri,当前支持微信读书、Flomo、Vercel",
5
5
  "bin": {
6
6
  "pake": "./cli.js"
@@ -18,7 +18,7 @@
18
18
  "dev": "npm run tauri dev",
19
19
  "build": "npm run tauri build -- --target universal-apple-darwin",
20
20
  "tauri": "tauri",
21
- "cli": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")",
21
+ "cli": "rollup -c rollup.config.js --watch",
22
22
  "cli:build": "rollup -c rollup.config.js"
23
23
  },
24
24
  "type": "module",
@@ -28,6 +28,7 @@
28
28
  "@tauri-apps/api": "^1.0.2",
29
29
  "app-root-path": "^3.1.0",
30
30
  "axios": "^1.1.3",
31
+ "commander": "^9.4.1",
31
32
  "file-type": "^18.0.0",
32
33
  "icojs": "^0.17.0",
33
34
  "is-url": "^1.2.4",
@@ -35,9 +36,8 @@
35
36
  "page-icon": "^0.4.0",
36
37
  "png2icons": "^2.0.1",
37
38
  "prompts": "^2.4.2",
38
- "tmp-promise": "^3.0.3",
39
- "commander": "^9.4.1",
40
- "shelljs": "^0.8.5"
39
+ "shelljs": "^0.8.5",
40
+ "tmp-promise": "^3.0.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@rollup/plugin-alias": "^4.0.2",
@@ -52,7 +52,9 @@
52
52
  "@types/tmp": "^0.2.3",
53
53
  "concurrently": "^7.5.0",
54
54
  "rollup": "^3.3.0",
55
+ "rollup-plugin-typescript2": "^0.34.1",
55
56
  "tsc-alias": "^1.7.1",
57
+ "tslib": "^2.4.1",
56
58
  "typescript": "^4.8.4"
57
59
  }
58
60
  }
package/rollup.config.js CHANGED
@@ -4,6 +4,7 @@ import typescript from '@rollup/plugin-typescript';
4
4
  import alias from '@rollup/plugin-alias';
5
5
  import commonjs from '@rollup/plugin-commonjs';
6
6
  import json from '@rollup/plugin-json';
7
+
7
8
  export default {
8
9
  input: 'bin/cli.ts',
9
10
  output: {