@giteeteam/apps-cli 0.1.12 → 0.1.15

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/index.js +35 -30
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -26,11 +26,9 @@ var simpleGit__default = /*#__PURE__*/_interopDefaultLegacy(simpleGit);
26
26
  var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
27
27
  var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
28
28
 
29
- var version = "0.1.12";
29
+ var version = "0.1.15";
30
30
 
31
- const packageApp = async (outputDir, manifest, _copyFiles = []) => {
32
- // add copy file manifest
33
- const copyFiles = ['manifest.yml', ..._copyFiles];
31
+ const packageApp = async ({ outputDir, manifest, copyFiles }) => {
34
32
  const { resources } = manifest;
35
33
  if (resources) {
36
34
  for (const { key, path: resourcePath } of resources) {
@@ -47,15 +45,8 @@ const packageApp = async (outputDir, manifest, _copyFiles = []) => {
47
45
  }
48
46
  };
49
47
 
50
- const readPkgName = async () => {
51
- const fileBuffer = await fse__default["default"].readFile(path__default["default"].resolve('./package.json'));
52
- const fileStr = fileBuffer.toString();
53
- const fileJson = JSON.parse(fileStr);
54
- return fileJson === null || fileJson === void 0 ? void 0 : fileJson.name;
55
- };
56
- const archiveApp = async (archiveDir) => {
57
- const pkgName = await readPkgName();
58
- const outputFile = path__default["default"].resolve(`./${pkgName}.zip`);
48
+ const archiveApp = async (archiveDir, pkgName) => {
49
+ const outputFile = path__default["default"].resolve(pkgName);
59
50
  await fse__default["default"].remove(outputFile);
60
51
  return new Promise((resolve, reject) => {
61
52
  const output = fse__default["default"].createWriteStream(outputFile);
@@ -133,9 +124,17 @@ const getManifestObject = async () => {
133
124
  return obj;
134
125
  };
135
126
 
136
- var run$1 = async (opts) => {
137
- const { outputDir, inputDir, prod, copyFiles, zip } = opts;
127
+ var run$1 = async ({ outputDir, inputDir, prod, copyFiles, zip }) => {
138
128
  const manifest = await getManifestObject();
129
+ const { app: { version, key }, } = manifest;
130
+ if (!key) {
131
+ console.error('manifest app key is required');
132
+ return;
133
+ }
134
+ if (!version) {
135
+ console.error('manifest app version is required');
136
+ return;
137
+ }
139
138
  // clear output dir
140
139
  await fse__default["default"].emptyDir(outputDir);
141
140
  // bundle
@@ -149,24 +148,26 @@ var run$1 = async (opts) => {
149
148
  start: 'start package',
150
149
  error: 'package failed',
151
150
  succeed: 'package success',
152
- }, () => packageApp(outputDir, manifest, copyFiles));
151
+ }, () => packageApp({ outputDir, manifest, copyFiles }));
153
152
  if (zip) {
153
+ const pkgName = `${key}_${version}.zip`;
154
154
  // archive
155
155
  await execActionWithSpinner({
156
156
  start: 'start archive',
157
157
  error: 'archive failed',
158
158
  succeed: 'archive success',
159
- }, () => archiveApp(outputDir));
159
+ }, () => archiveApp(outputDir, pkgName));
160
160
  }
161
161
  };
162
162
 
163
+ const defaultCopyFiles = ['manifest.yml'];
163
164
  var build = async (options) => {
164
- const { input = 'src', output = 'dist', prod, copy, zip } = options;
165
+ const { input = 'src', output = 'dist', prod, copy = [], zip } = options;
165
166
  await run$1({
166
167
  outputDir: path__default["default"].resolve(output),
167
168
  inputDir: path__default["default"].resolve(input),
168
169
  prod: !!prod,
169
- copyFiles: copy,
170
+ copyFiles: [...defaultCopyFiles, ...copy],
170
171
  zip: zip,
171
172
  });
172
173
  };
@@ -189,7 +190,7 @@ const templateURL = 'https://github.com/moriahq/apps-template.git';
189
190
  var TemplateType;
190
191
  (function (TemplateType) {
191
192
  TemplateType["micro"] = "micro";
192
- TemplateType["uikit"] = "uikit";
193
+ // 'uikit' = 'uikit',
193
194
  })(TemplateType || (TemplateType = {}));
194
195
  // 重写替换文件内带模版的地方。格式为 {{field}}
195
196
  // options为字段变量
@@ -256,30 +257,30 @@ const selectTemplate = async () => {
256
257
  const prompt = inquirer__default["default"].createPromptModule();
257
258
  const result = await prompt({
258
259
  type: 'list',
259
- name: '请选择插件类型',
260
+ name: 'Please select template type',
260
261
  choices: Object.keys(TemplateType),
261
262
  });
262
263
  return Object.values(result)[0];
263
264
  };
264
265
  const cloneRepo = async (repoUrl, projectPath) => {
265
266
  await execActionWithSpinner({
266
- start: '开始克隆仓库',
267
- error: '仓库克隆失败',
268
- succeed: '仓库克隆完毕',
267
+ start: 'Start clone repository',
268
+ error: 'Clone repository failed!',
269
+ succeed: 'Clone repository success!',
269
270
  }, () => clone(repoUrl, projectPath));
270
271
  };
271
272
  const dependenciesInstall = async (projectPath) => {
272
273
  await execActionWithSpinner({
273
- start: '开始安装依赖',
274
- error: '依赖安装失败',
275
- succeed: '依赖安装成功',
274
+ start: 'Start install dependencies',
275
+ error: 'Install dependencies failed!',
276
+ succeed: 'Install dependencies success!',
276
277
  }, () => command.executeCommand('yarn', ['install'], projectPath));
277
278
  };
278
279
  var run = async (options) => {
279
280
  const { cwd, packageName } = options;
280
281
  const projectPath = path__default["default"].join(cwd, packageName);
281
282
  if (await fse__default["default"].pathExists(projectPath)) {
282
- console.error('项目文件夹已存在!请删除或者换个项目名');
283
+ console.error('Project path already exists!');
283
284
  return;
284
285
  }
285
286
  // 选择模板类型 micro or uikit
@@ -296,6 +297,10 @@ var run = async (options) => {
296
297
  const files = [
297
298
  './manifest.yml',
298
299
  './package.json',
300
+ './webpack.config.js',
301
+ './public/index.html',
302
+ './src/App.tsx',
303
+ './src/index.tsx',
299
304
  './static/micro/package.json',
300
305
  './static/micro/webpack.config.js',
301
306
  './static/micro/public/index.html',
@@ -309,8 +314,8 @@ var run = async (options) => {
309
314
  })));
310
315
  await dependenciesInstall(projectPath);
311
316
  await init(projectPath);
312
- console.log('项目初始化成功!');
313
- console.log('项目路径:' + projectPath);
317
+ console.log('Project init success!');
318
+ console.log('Project path:' + projectPath);
314
319
  };
315
320
 
316
321
  var create = async (packageName) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-cli",
3
- "version": "0.1.12",
3
+ "version": "0.1.15",
4
4
  "description": "Giteeteam Apps cli",
5
5
  "keywords": [
6
6
  "typescript",
@@ -8,7 +8,7 @@
8
8
  "cli"
9
9
  ],
10
10
  "bin": {
11
- "giteeteam-apps-cli": "./dist/index.js"
11
+ "giteeteam-apps": "./dist/index.js"
12
12
  },
13
13
  "license": "ISC",
14
14
  "main": "./dist/index.js",
@@ -56,5 +56,5 @@
56
56
  "@types/inquirer": "^8.2.1",
57
57
  "@types/uuid": "^8.3.4"
58
58
  },
59
- "gitHead": "0030d0a92683b04230c31a1f27b747a5c73480cb"
59
+ "gitHead": "e6150c7c1dd0a090fb03c0b506bd530ae19976a3"
60
60
  }