@lakutata/cli 2.2.0 → 2.4.0

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,35 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.4.0](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.3.0...@lakutata/cli@2.4.0) (2024-08-02)
7
+
8
+
9
+ ### Features
10
+
11
+ * **cli:** update initOnly option to overwrite option ([9822407](https://github.com/lakutata/lakutata-packages/commit/982240776987ee281ed95e5a507ceac884146a75))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.3.0](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.2.0...@lakutata/cli@2.3.0) (2024-04-15)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * Fix import statements in CLIApp.ts and Information.ts ([bff006b](https://github.com/lakutata/lakutata-packages/commit/bff006b9adb51fc95bc0d018950d9b88493d60ad))
23
+
24
+
25
+ ### Features
26
+
27
+ * **cli:** add initialization step after project creation ([5843178](https://github.com/lakutata/lakutata-packages/commit/5843178bfb91f1420921717fc1f63b7f11dfd48a))
28
+ * **cli:** update dependencies and improve installation process ([fd70167](https://github.com/lakutata/lakutata-packages/commit/fd70167d37b3f9af738272ac2e8599d45bc26347))
29
+ * Update lakutata package to version 2.0.2 ([e3c0b22](https://github.com/lakutata/lakutata-packages/commit/e3c0b22e65ae250f396e8b71137f41c61049df5b))
30
+
31
+
32
+
33
+
34
+
6
35
  # [2.2.0](https://github.com/lakutata/lakutata-packages/compare/@lakutata/cli@2.1.0-alpha.5...@lakutata/cli@2.2.0) (2024-04-15)
7
36
 
8
37
 
package/dist/CLIApp.js CHANGED
@@ -1,5 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
3
26
  Object.defineProperty(exports, "__esModule", { value: true });
4
27
  const commander_1 = require("commander");
5
28
  const CommandLineController_1 = require("./controllers/CommandLineController");
@@ -11,6 +34,8 @@ const Spinner_1 = require("./lib/components/Spinner");
11
34
  const cli_spinners_1 = require("cli-spinners");
12
35
  const lakutata_1 = require("lakutata");
13
36
  const entrypoint_1 = require("lakutata/com/entrypoint");
37
+ const console = __importStar(require("node:console"));
38
+ const OnlineLatestVersion_1 = require("./lib/providers/OnlineLatestVersion");
14
39
  lakutata_1.Application.run(async () => ({
15
40
  id: 'cli.lakutata.app',
16
41
  name: 'Lakutata-CLI',
@@ -27,6 +52,7 @@ lakutata_1.Application.run(async () => ({
27
52
  style: cli_spinners_1.dots
28
53
  },
29
54
  entrypoint: (0, entrypoint_1.BuildEntrypoints)({
55
+ controllers: [CommandLineController_1.CommandLineController],
30
56
  cli: (0, entrypoint_1.BuildCLIEntrypoint)((module, cliMap, handler, registerDestroy) => {
31
57
  const CLIProgram = new commander_1.Command();
32
58
  cliMap.forEach((dtoJsonSchema, command) => {
@@ -64,9 +90,13 @@ lakutata_1.Application.run(async () => ({
64
90
  license: package_json_1.license,
65
91
  currentDirectory: __dirname,
66
92
  workingDirectory: process.cwd()
93
+ },
94
+ onlineVersion: {
95
+ class: OnlineLatestVersion_1.OnlineLatestVersion,
96
+ name: package_json_1.name,
97
+ version: package_json_1.version
67
98
  }
68
99
  },
69
- controllers: [CommandLineController_1.CommandLineController],
70
100
  bootstrap: ['entrypoint']
71
101
  }))
72
102
  .onUncaughtException((error) => {
@@ -2,7 +2,8 @@ import { CreateProjectOptions } from '../options/CreateProjectOptions';
2
2
  import { LakutataInfoOptions } from '../options/LakutataInfoOptions';
3
3
  import { Information } from '../lib/providers/Information';
4
4
  import { Creator } from '../lib/providers/Creator';
5
- import { type ActionPattern, Controller } from 'lakutata';
5
+ import { type ActionPattern } from 'lakutata';
6
+ import { Controller } from 'lakutata/com/entrypoint';
6
7
  export declare class CommandLineController extends Controller {
7
8
  protected readonly projectCreator: Creator;
8
9
  protected readonly frameworkInfo: Information;
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineController.d.ts","sourceRoot":"","sources":["../../src/controllers/CommandLineController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAC,KAAK,aAAa,EAAE,UAAU,EAAC,MAAM,UAAU,CAAA;AAIvD,qBAAa,qBAAsB,SAAQ,UAAU;IAGjD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAG1C,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAA;IAE7C;;;OAGG;IAEU,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5E;;;OAGG;IAEU,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5E"}
1
+ {"version":3,"file":"CommandLineController.d.ts","sourceRoot":"","sources":["../../src/controllers/CommandLineController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAC,KAAK,aAAa,EAAC,MAAM,UAAU,CAAA;AAG3C,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAElD,qBAAa,qBAAsB,SAAQ,UAAU;IAGjD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAG1C,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAA;IAE7C;;;OAGG;IAEU,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5E;;;OAGG;IAEU,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5E"}
@@ -14,10 +14,10 @@ const CreateProjectOptions_1 = require("../options/CreateProjectOptions");
14
14
  const LakutataInfoOptions_1 = require("../options/LakutataInfoOptions");
15
15
  const Information_1 = require("../lib/providers/Information");
16
16
  const Creator_1 = require("../lib/providers/Creator");
17
- const lakutata_1 = require("lakutata");
18
17
  const di_1 = require("lakutata/decorator/di");
19
18
  const ctrl_1 = require("lakutata/decorator/ctrl");
20
- class CommandLineController extends lakutata_1.Controller {
19
+ const entrypoint_1 = require("lakutata/com/entrypoint");
20
+ class CommandLineController extends entrypoint_1.Controller {
21
21
  /**
22
22
  * Create project
23
23
  * @param inp
@@ -1 +1 @@
1
- {"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Spinner.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,KAAK,OAAO,IAAI,UAAU,EAAO,MAAM,cAAc,CAAA;AAE7D,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAGlC,qBACa,OAAQ,SAAQ,SAAS;IAGlC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAO;IAE3C,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAO;IAEvD,SAAS,CAAC,SAAS,EAAE,GAAG,CAAA;IAExB;;;OAGG;cACa,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC;;;OAGG;IACI,KAAK,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI;IAUzD;;OAEG;IACI,IAAI,IAAI,IAAI;CAOtB"}
1
+ {"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Spinner.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,KAAK,OAAO,IAAI,UAAU,EAAO,MAAM,cAAc,CAAA;AAE7D,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAElC,qBACa,OAAQ,SAAQ,SAAS;IAGlC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAO;IAE3C,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAO;IAEvD,SAAS,CAAC,SAAS,EAAE,GAAG,CAAA;IAExB;;;OAGG;cACa,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC;;;OAGG;IACI,KAAK,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI;IAUzD;;OAEG;IACI,IAAI,IAAI,IAAI;CAOtB"}
@@ -13,7 +13,6 @@ exports.Spinner = void 0;
13
13
  const cli_spinners_1 = require("cli-spinners");
14
14
  const di_1 = require("lakutata/decorator/di");
15
15
  const lakutata_1 = require("lakutata");
16
- const helper_1 = require("lakutata/helper");
17
16
  let Spinner = class Spinner extends lakutata_1.Component {
18
17
  constructor() {
19
18
  super(...arguments);
@@ -25,7 +24,7 @@ let Spinner = class Spinner extends lakutata_1.Component {
25
24
  * @protected
26
25
  */
27
26
  async init() {
28
- this.logUpdate = (0, helper_1.As)(await import('log-update'));
27
+ this.logUpdate = require('log-update').default;
29
28
  }
30
29
  /**
31
30
  * Start spinner
@@ -4,12 +4,14 @@ import { Spinner } from '../components/Spinner.js';
4
4
  import { CreateProjectOptions } from '../../options/CreateProjectOptions.js';
5
5
  import { Application, Provider } from 'lakutata';
6
6
  import { Logger } from 'lakutata/com/logger';
7
+ import { OnlineLatestVersion } from './OnlineLatestVersion';
7
8
  export declare class Creator extends Provider {
8
9
  protected readonly app: Application;
9
10
  protected readonly log: Logger;
10
11
  protected readonly spinner: Spinner;
11
12
  protected readonly puller: DeGitPuller;
12
13
  protected readonly frameworkInfo: Information;
14
+ protected readonly onlineVersion: OnlineLatestVersion;
13
15
  /**
14
16
  * Check if the target path exists
15
17
  * @param targetDirectory
@@ -1 +1 @@
1
- {"version":3,"file":"Creator.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/Creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAM1E,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,UAAU,CAAA;AAE9C,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAM1C,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GnC,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IAG9B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IAGnC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAGtC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAA;IAG7C,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAAA;IAErD;;;;;OAKG;cACa,wBAAwB,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAUnG;;;;OAIG;cACa,0BAA0B,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASlF;;;;OAIG;cACa,2BAA2B,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASnF;;;OAGG;IAEU,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkDpE"}
@@ -28,6 +28,7 @@ const helper_1 = require("lakutata/helper");
28
28
  const dto_1 = require("lakutata/decorator/dto");
29
29
  const ansis_1 = __importDefault(require("ansis"));
30
30
  const cli_table3_1 = __importDefault(require("cli-table3"));
31
+ const OnlineLatestVersion_1 = require("./OnlineLatestVersion");
31
32
  class Creator extends lakutata_1.Provider {
32
33
  /**
33
34
  * Check if the target path exists
@@ -78,14 +79,14 @@ class Creator extends lakutata_1.Provider {
78
79
  const appName = options.name;
79
80
  const appId = options.id;
80
81
  const appDescription = options.description;
81
- const packageName = appId;
82
+ // const packageName: string = appId
82
83
  const authorName = options.author;
83
84
  const licenseName = options.license;
84
85
  const appType = options.type;
85
- const targetPath = options.initOnly ? node_path_1.default.resolve(options.path) : node_path_1.default.resolve(options.path, options.name);
86
+ const targetPath = options.overwrite ? node_path_1.default.resolve(options.path) : node_path_1.default.resolve(options.path, options.name);
86
87
  const { branch } = ProjectTypeConfig_js_1.ProjectTypeConfig[appType];
87
88
  const table = new cli_table3_1.default();
88
- table.push([{ content: ansis_1.default.bold.cyan('Project Creation Information'), colSpan: 2, hAlign: 'center' }], [ansis_1.default.blue('APP ID & Project Name'), appId], [ansis_1.default.blue('APP Name'), appName], [ansis_1.default.blue('APP Description'), appDescription], [ansis_1.default.blue('Project Create Target Path'), targetPath], [ansis_1.default.blue('Project Create Mode'), options.initOnly ? ansis_1.default.yellow('Initialize project in an existing directory') : ansis_1.default.green('Create a new folder for the project')], [ansis_1.default.blue('Project Author Name'), authorName], [ansis_1.default.blue('Project License'), licenseName], [ansis_1.default.blue('Project Template Branch'), this.puller.getGitSource(branch)]);
89
+ table.push([{ content: ansis_1.default.bold.cyan('Project Creation Information'), colSpan: 2, hAlign: 'center' }], [ansis_1.default.blue('APP ID & Project Name'), appId], [ansis_1.default.blue('APP Name'), appName], [ansis_1.default.blue('APP Description'), appDescription], [ansis_1.default.blue('Project Create Target Path'), targetPath], [ansis_1.default.blue('Project Create Mode'), options.overwrite ? ansis_1.default.yellow('Initialize project in an existing directory') : ansis_1.default.green('Create a new folder for the project')], [ansis_1.default.blue('Project Author Name'), authorName], [ansis_1.default.blue('Project License'), licenseName], [ansis_1.default.blue('Project Template Branch'), this.puller.getGitSource(branch)]);
89
90
  console.log(table.toString());
90
91
  await new Promise(resolve => {
91
92
  let timeLeft = 15;
@@ -99,11 +100,20 @@ class Creator extends lakutata_1.Provider {
99
100
  }, 1000);
100
101
  this.spinner.start(() => `Please confirm the project creation information; the creation process will commence in ${timeLeft} seconds.`);
101
102
  });
102
- await this.checkTargetPathExistence(targetPath, options.initOnly);
103
+ await this.checkTargetPathExistence(targetPath, options.overwrite);
103
104
  await this.checkTargetPathIsDirectory(targetPath);
104
105
  await this.checkTargetDirectoryIsEmpty(targetPath);
105
- this.log.info('Begin project creation');
106
- //TODO
106
+ this.spinner.start('Pulling');
107
+ await this.puller.pull(branch, targetPath);
108
+ this.spinner.stop();
109
+ this.log.info(`${SpecialChar_js_1.charCheck} Template pulled.`);
110
+ this.spinner.start('Installing');
111
+ //TODO 将项目内的内容进行初始化
112
+ const { execa } = await import('execa');
113
+ await execa('npm', ['install'], { cwd: targetPath });
114
+ await execa('npm', ['install', `${this.onlineVersion.getName()}@${await this.onlineVersion.getVersion()}`], { cwd: targetPath });
115
+ this.spinner.stop();
116
+ this.log.info(`${SpecialChar_js_1.charCheck} Project has been successfully created.`);
107
117
  }
108
118
  }
109
119
  exports.Creator = Creator;
@@ -125,7 +135,11 @@ __decorate([
125
135
  ], Creator.prototype, "puller", void 0);
126
136
  __decorate([
127
137
  (0, di_1.Inject)('info'),
128
- __metadata("design:type", Information_js_1.Information
138
+ __metadata("design:type", Information_js_1.Information)
139
+ ], Creator.prototype, "frameworkInfo", void 0);
140
+ __decorate([
141
+ (0, di_1.Inject)('onlineVersion'),
142
+ __metadata("design:type", OnlineLatestVersion_1.OnlineLatestVersion
129
143
  /**
130
144
  * Check if the target path exists
131
145
  * @param targetDirectory
@@ -133,7 +147,7 @@ __decorate([
133
147
  * @protected
134
148
  */
135
149
  )
136
- ], Creator.prototype, "frameworkInfo", void 0);
150
+ ], Creator.prototype, "onlineVersion", void 0);
137
151
  __decorate([
138
152
  (0, dto_1.Accept)(CreateProjectOptions_js_1.CreateProjectOptions.required()),
139
153
  __metadata("design:type", Function),
@@ -1 +1 @@
1
- {"version":3,"file":"Information.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/Information.ts"],"names":[],"mappings":"AAGA,OAAO,EAAM,QAAQ,EAAO,MAAM,UAAU,CAAA;AAI5C,qBAAa,WAAY,SAAQ,QAAQ;IAGrC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAG/B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAGlC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAGtC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;I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AEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACU,wCAAwC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAe/E;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAYtC"}
@@ -33,7 +33,8 @@ class Information extends lakutata_1.Provider {
33
33
  if (projectRoot) {
34
34
  const packageJsonPath = (0, node_path_1.resolve)(projectRoot, './package.json');
35
35
  try {
36
- const packageJson = JSON.parse(await (0, promises_1.readFile)(packageJsonPath, { encoding: 'utf-8' }));
36
+ const rawPackageJsonBuffer = await (0, promises_1.readFile)(packageJsonPath);
37
+ const packageJson = JSON.parse(rawPackageJsonBuffer.toString());
37
38
  const dependenciesKeyRegExp = new RegExp('dependencies'.toUpperCase());
38
39
  Object.keys(packageJson).forEach((key) => {
39
40
  if (dependenciesKeyRegExp.test(key.toUpperCase())) {
@@ -170,7 +171,9 @@ class Information extends lakutata_1.Provider {
170
171
  const projectRoot = this.getRoot();
171
172
  if (projectRoot) {
172
173
  try {
173
- const version = JSON.parse(await (0, promises_1.readFile)((0, node_path_1.resolve)(projectRoot, './node_modules', `./${this.name}/package.json`), { encoding: 'utf-8' })).version;
174
+ const pkgJsonBuffer = await (0, promises_1.readFile)((0, node_path_1.resolve)(projectRoot, './node_modules', `./${this.name}/package.json`));
175
+ const pkgJson = JSON.parse(pkgJsonBuffer.toString());
176
+ const version = pkgJson.version;
174
177
  return version ? version : null;
175
178
  }
176
179
  catch (e) {
@@ -0,0 +1,14 @@
1
+ import { Provider } from 'lakutata';
2
+ export declare class OnlineLatestVersion extends Provider {
3
+ protected readonly version: string;
4
+ protected readonly name: string;
5
+ /**
6
+ * Get package name
7
+ */
8
+ getName(): string;
9
+ /**
10
+ * Get latest version
11
+ */
12
+ getVersion(): Promise<string>;
13
+ }
14
+ //# sourceMappingURL=OnlineLatestVersion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OnlineLatestVersion.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/OnlineLatestVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAA;AAIjC,qBAAa,mBAAoB,SAAQ,QAAQ;IAG7C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAGlC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAE/B;;OAEG;IACI,OAAO,IAAI,MAAM;IAIxB;;OAEG;IACU,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;CAW7C"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OnlineLatestVersion = void 0;
13
+ const lakutata_1 = require("lakutata");
14
+ const di_1 = require("lakutata/decorator/di");
15
+ const semver_1 = require("semver");
16
+ class OnlineLatestVersion extends lakutata_1.Provider {
17
+ /**
18
+ * Get package name
19
+ */
20
+ getName() {
21
+ return this.name;
22
+ }
23
+ /**
24
+ * Get latest version
25
+ */
26
+ async getVersion() {
27
+ let onlineLatestVersion;
28
+ const prereleaseInfo = (0, semver_1.prerelease)(this.version);
29
+ if (prereleaseInfo && prereleaseInfo[0]) {
30
+ onlineLatestVersion = await require('latest-version').default(this.name, { version: prereleaseInfo[0].toString() });
31
+ }
32
+ else {
33
+ onlineLatestVersion = await require('latest-version').default(this.name);
34
+ }
35
+ return (0, semver_1.gt)(onlineLatestVersion, this.version) ? onlineLatestVersion : this.version;
36
+ }
37
+ }
38
+ exports.OnlineLatestVersion = OnlineLatestVersion;
39
+ __decorate([
40
+ (0, di_1.Configurable)(),
41
+ __metadata("design:type", String)
42
+ ], OnlineLatestVersion.prototype, "version", void 0);
43
+ __decorate([
44
+ (0, di_1.Configurable)(),
45
+ __metadata("design:type", String)
46
+ ], OnlineLatestVersion.prototype, "name", void 0);
@@ -7,7 +7,7 @@ export declare class CreateProjectOptions extends DTO {
7
7
  id: string;
8
8
  type: string;
9
9
  path: string;
10
- initOnly: boolean;
10
+ overwrite: boolean;
11
11
  description: string;
12
12
  author: string;
13
13
  license: string;
@@ -1 +1 @@
1
- {"version":3,"file":"CreateProjectOptions.d.ts","sourceRoot":"","sources":["../../src/options/CreateProjectOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;AAG5B;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,GAAG;IASlC,IAAI,EAAE,MAAM,CAAA;IASZ,EAAE,EAAE,MAAM,CAAA;IASV,IAAI,EAAE,MAAM,CAAA;IASZ,IAAI,EAAE,MAAM,CAAA;IAUZ,QAAQ,EAAE,OAAO,CAAA;IASjB,WAAW,EAAE,MAAM,CAAA;IASnB,MAAM,EAAE,MAAM,CAAA;IASd,OAAO,EAAE,MAAM,CAAA;CACzB"}
1
+ {"version":3,"file":"CreateProjectOptions.d.ts","sourceRoot":"","sources":["../../src/options/CreateProjectOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;AAG5B;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,GAAG;IASlC,IAAI,EAAE,MAAM,CAAA;IASZ,EAAE,EAAE,MAAM,CAAA;IASV,IAAI,EAAE,MAAM,CAAA;IASZ,IAAI,EAAE,MAAM,CAAA;IAUZ,SAAS,EAAE,OAAO,CAAA;IASlB,WAAW,EAAE,MAAM,CAAA;IASnB,MAAM,EAAE,MAAM,CAAA;IASd,OAAO,EAAE,MAAM,CAAA;CACzB"}
@@ -57,9 +57,9 @@ __decorate([
57
57
  .strict(false)
58
58
  .optional()
59
59
  .default(false)
60
- .description('initialize project only in specified directory without creating a new folder (default: false)')),
60
+ .description('initialize the project within an existing folder (default: false)')),
61
61
  __metadata("design:type", Boolean)
62
- ], CreateProjectOptions.prototype, "initOnly", void 0);
62
+ ], CreateProjectOptions.prototype, "overwrite", void 0);
63
63
  __decorate([
64
64
  (0, dto_1.Expect)(lakutata_1.DTO
65
65
  .String()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lakutata/cli",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "Lakutata CLI tool",
5
5
  "keywords": [
6
6
  "lakutata",
@@ -24,7 +24,8 @@
24
24
  "clean": "shx rm -rf ./dist",
25
25
  "build": "tsc",
26
26
  "rebuild": "npm run clean && npm run build",
27
- "test": "node ./__tests__/@lakutata/cli.test.js"
27
+ "test:info": "tsx src/CLIApp.ts info",
28
+ "test:create": "tsx src/CLIApp.ts create --help"
28
29
  },
29
30
  "bugs": {
30
31
  "url": "https://github.com/lakutata/lakutata-packages/issues"
@@ -35,11 +36,14 @@
35
36
  "cli-table3": "^0.6.4",
36
37
  "commander": "^12.0.0",
37
38
  "degit": "^2.8.4",
39
+ "execa": "^8.0.1",
40
+ "latest-version": "^9.0.0",
38
41
  "log-update": "^6.0.0",
39
- "pkg-dir": "^8.0.0"
42
+ "pkg-dir": "^8.0.0",
43
+ "semver": "^7.6.0"
40
44
  },
41
45
  "devDependencies": {
42
46
  "@types/degit": "^2.8.6"
43
47
  },
44
- "gitHead": "ebaf7d19a98ed571903a0ee9ed7fc37a0ea1b018"
48
+ "gitHead": "bdd216bfdabfff7dfa87027894dc86cb38316c04"
45
49
  }