@marsx-dev/launcher 0.0.2 → 0.0.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 (2) hide show
  1. package/dist/cli/init.js +66 -36
  2. package/package.json +10 -52
package/dist/cli/init.js CHANGED
@@ -1,27 +1,4 @@
1
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
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
@@ -31,16 +8,57 @@ const chalk_1 = __importDefault(require("chalk"));
31
8
  const child_process_1 = require("child_process");
32
9
  const crypto_1 = require("crypto");
33
10
  const path_1 = __importDefault(require("path"));
34
- const util = __importStar(require("util"));
35
11
  const utils_1 = require("../utils/utils");
36
12
  const index_1 = require("./index");
37
- const execAsync = util.promisify(child_process_1.exec);
38
- const DEMO_BOOTER = `<json id="metadata">
13
+ const FASTIFY_DEPS = [
14
+ '@fastify/session',
15
+ 'fastify',
16
+ 'fastify-accepts',
17
+ 'fastify-compress',
18
+ 'fastify-cookie',
19
+ 'fastify-cors',
20
+ 'fastify-csrf',
21
+ 'fastify-flash',
22
+ 'fastify-formbody',
23
+ 'fastify-helmet',
24
+ 'fastify-multipart',
25
+ 'fastify-request-context',
26
+ 'fastify-static',
27
+ 'fastify-websocket',
28
+ ];
29
+ const COMMON_DEPS = [
30
+ '@marsx-dev/launcher',
31
+ 'aws-sdk',
32
+ 'axios',
33
+ 'azure-storage',
34
+ 'base-x',
35
+ 'bcrypt',
36
+ 'chokidar',
37
+ 'lodash',
38
+ 'mongodb4@npm:mongodb@4',
39
+ 'mongodb3@npm:mongodb@3',
40
+ 'typescript',
41
+ 'uuid',
42
+ 'xxhash',
43
+ ];
44
+ const V3_DEPS = [
45
+ 'babel-core',
46
+ 'babel-plugin-transform-react-jsx',
47
+ 'config',
48
+ 'crypto-js',
49
+ 'jsonwebtoken',
50
+ 'mobile-detect',
51
+ 'moment-timezone',
52
+ 'route-pattern',
53
+ 'route-sort',
54
+ ];
55
+ const DEFAULT_DEPS = [...FASTIFY_DEPS, ...COMMON_DEPS, ...V3_DEPS];
56
+ const DEMO_BOOTER = `<json id='metadata'>
39
57
  {"version": 4, "restartOnChange": true}
40
58
  </json>
41
59
 
42
60
 
43
- <script id="BlockFunction" lang="tsx">
61
+ <script id='BlockFunction' lang='tsx'>
44
62
  export default async () => {
45
63
  console.log('MarsX loaded!')
46
64
  };
@@ -61,9 +79,7 @@ async function initProject(projectName) {
61
79
  scripts: {
62
80
  start: 'marsx start',
63
81
  },
64
- dependencies: {
65
- '@marsx-dev/launcher': '^0.0.1',
66
- },
82
+ dependencies: {},
67
83
  };
68
84
  const packageJsonStr = JSON.stringify(packageJson, null, 2);
69
85
  await (0, utils_1.writeFileMakeDir)(path_1.default.join(projectDir, 'package.json'), packageJsonStr);
@@ -72,7 +88,7 @@ async function initProject(projectName) {
72
88
  port: 3000,
73
89
  blocksDir: 'blocks',
74
90
  cacheDir: '.cache',
75
- mongoConn: '<YOUR_MONGO_CONN_STR>',
91
+ mongoConn: '<CONN_STR>',
76
92
  mongoDbName: projectName,
77
93
  azureStorageConnection: '<CONN_STR>',
78
94
  azureStorageAccountName: projectName,
@@ -81,15 +97,29 @@ async function initProject(projectName) {
81
97
  webRecentFilesTable: 'webRecentFiles',
82
98
  webFilesBlob: 'web-files',
83
99
  secret: (await (0, crypto_1.randomBytes)(48)).toString('hex'),
84
- importProjects: [{ name: 'mars-ide', url: 'https://ide.marscloud.dev', api_key: '<API_KEY>', git_commit_ish: 'main' }],
100
+ importProjects: [
101
+ {
102
+ name: 'mars-ide',
103
+ url: 'https://ide.marscloud.dev',
104
+ api_key: '<API_KEY>',
105
+ git_commit_ish: 'main',
106
+ },
107
+ ],
85
108
  };
86
109
  await (0, utils_1.writeFileMakeDir)(path_1.default.join(projectDir, 'config', 'default.json'), JSON.stringify(config, null, 2));
110
+ await (0, utils_1.writeFileMakeDir)(path_1.default.join(projectDir, '.gitignore'), 'node_modules\ndist');
87
111
  await (0, utils_1.writeFileMakeDir)(path_1.default.join(projectDir, 'blocks', 'Booter.service.vue'), DEMO_BOOTER);
112
+ function run(...args) {
113
+ const cmd = args[0];
114
+ (0, utils_1.assert)(cmd);
115
+ (0, child_process_1.spawnSync)(cmd, args.slice(1), { cwd: projectDir, stdio: 'inherit' });
116
+ }
88
117
  console.log('Installing dependencies. This might take a couple of minutes.');
89
- await execAsync('npm install', { cwd: projectDir });
90
- await execAsync('git init', { cwd: projectDir });
91
- await execAsync('git add -A', { cwd: projectDir });
92
- await execAsync('git commit -m "Initial commit"', { cwd: projectDir });
118
+ run('npm', 'i', ...DEFAULT_DEPS);
119
+ run('git', 'init');
120
+ run('git', 'add', '.gitignore');
121
+ run('git', 'add', '-A');
122
+ run('git', 'commit', '-m', 'Initial commit');
93
123
  console.log('Initialized git repository and created initial commit.');
94
124
  console.log(chalk_1.default.yellow(`\nMake sure to update parameters in config/default.json`));
95
125
  console.log(`${chalk_1.default.green('Success!')} Created ${projectName} at ${projectDir}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marsx-dev/launcher",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "MarsX launcher",
5
5
  "author": "MarsX team <team@marsx.dev>",
6
6
  "homepage": "https://marsx.dev/",
@@ -39,67 +39,25 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@vue/compiler-sfc": "^3.2.29",
42
- "axios": "^0.26.1",
43
42
  "chalk": "^4.1.2",
44
43
  "commander": "^9.1.0",
45
- "config": "^3.3.7",
46
44
  "json-stable-stringify": "^1.0.1",
47
- "json5": "^2.2.0",
45
+ "json5": "^2.2.0"
46
+ },
47
+ "peerDependencies": {
48
+ "@types/config": "^0.0.41",
49
+ "@types/lodash": "^4.14.178",
50
+ "@types/node": "^17.0.21",
51
+ "@types/prettier": "^2.4.4",
52
+ "axios": "^0.26.1",
53
+ "config": "^3.3.7",
48
54
  "lodash": "^4.17.21",
49
55
  "mongodb": "^4.3.1",
50
56
  "prettier": "^2.5.1",
51
57
  "typescript": "^4.5.5"
52
58
  },
53
- "peerDependencies": {
54
- "@fastify/session": "^6.4.0",
55
- "@stitches/core": "^1.2.6",
56
- "@types/accepts": "^1.3.5",
57
- "@types/bcrypt": "^5.0.0",
58
- "@types/mkdirp": "^1.0.2",
59
- "@types/nodegit": "^0.27.9",
60
- "@types/sharp": "^0.29.5",
61
- "@types/uuid": "^8.3.4",
62
- "@types/ws": "^8.5.2",
63
- "aws-sdk": "^2.1073.0",
64
- "azure-storage": "^2.10.7",
65
- "babel-core": "^6.26.3",
66
- "babel-plugin-transform-react-jsx": "^6.24.1",
67
- "base-x": "^4.0.0",
68
- "bcrypt": "^5.0.1",
69
- "chokidar": "^3.5.3",
70
- "dotenv": "^16.0.0",
71
- "fastify": "^3.27.2",
72
- "fastify-accepts": "^2.1.0",
73
- "fastify-compress": "^4.0.1",
74
- "fastify-cookie": "^5.6.0",
75
- "fastify-cors": "^6.0.3",
76
- "fastify-csrf": "^3.1.0",
77
- "fastify-flash": "^2.0.2",
78
- "fastify-formbody": "^5.2.0",
79
- "fastify-helmet": "^7.0.1",
80
- "fastify-multipart": "^5.3.1",
81
- "fastify-request-context": "^2.2.0",
82
- "fastify-static": "^4.5.0",
83
- "fastify-websocket": "^4.2.0",
84
- "fontverter": "^2.0.0",
85
- "jsonwebtoken": "^8.5.1",
86
- "mobile-detect": "^1.4.5",
87
- "moment-timezone": "^0.5.34",
88
- "nodegit": "^0.28.0-alpha.10",
89
- "route-pattern": "^0.0.6",
90
- "route-sort": "^1.0.0",
91
- "sharp": "^0.30.1",
92
- "source-map": "^0.7.3",
93
- "subset-font": "^1.4.0",
94
- "uuid": "^8.3.2",
95
- "xxhash": "^0.3.0"
96
- },
97
59
  "devDependencies": {
98
- "@types/config": "^0.0.41",
99
60
  "@types/json-stable-stringify": "^1.0.34",
100
- "@types/lodash": "^4.14.178",
101
- "@types/node": "^17.0.21",
102
- "@types/prettier": "^2.4.4",
103
61
  "@typescript-eslint/eslint-plugin": "^5.10.2",
104
62
  "@typescript-eslint/parser": "^5.10.2",
105
63
  "eslint": "^8.8.0",