New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koatty_cli

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koatty_cli - npm Package Compare versions

Comparing version 3.0.12 to 3.1.0

2

package.json
{
"name": "koatty_cli",
"version": "3.0.12",
"version": "3.1.0",
"description": "Koatty command line tool.",

@@ -5,0 +5,0 @@ "scripts": {

# koatty_cli
Koatty command line tool.
## Usage
# Usage
### 1.Create Project
## Create koatty project

@@ -13,3 +13,3 @@ ```shell

yarn install
yarn install // or npm i

@@ -19,3 +19,5 @@ npm start

### 2.Create a Controller
## Create a module in the koatty project
* 1.Create a Controller
```shell

@@ -26,3 +28,3 @@ koatty controller test

### 3.Create a Service
* 2.Create a Service

@@ -34,3 +36,3 @@ ```shell

### 3.Create a Middleware
* 3.Create a Middleware

@@ -42,3 +44,3 @@ ```shell

### 4.Create a Model
* 4.Create a Model

@@ -56,3 +58,3 @@ ```shell

### 5.Create a Aspect
* 5.Create a Aspect

@@ -85,3 +87,3 @@ 定义切面类:

### 5.Create a DTO class
* 6.Create a DTO class

@@ -124,2 +126,28 @@ 定义数据验证类:

```
## Create Koatty Extension Project
* 1、Create a Middleware Project
```shell
koatty new projectName -t middleware
cd ./projectName
yarn install // or npm i
npm start
```
* 2、Create a Plugin Project
```shell
koatty new projectName -t plugin
cd ./projectName
yarn install // or npm i
npm start
```

@@ -6,3 +6,3 @@ /*

* @Date: 2020-12-22 17:29:34
* @LastEditTime: 2020-12-22 17:47:51
* @LastEditTime: 2020-12-24 11:23:26
*/

@@ -13,2 +13,4 @@

TEMPLATE_URL: 'https://github.com/Koatty/koatty_template.git',
COMP_TEMPLATE_NAME: 'koatty_template_component',
COMP_TEMPLATE_URL: 'https://github.com/Koatty/koatty_template_component.git#main',

@@ -15,0 +17,0 @@ LOGO: `

@@ -6,3 +6,3 @@ /*

* @Date: 2020-12-08 15:08:37
* @LastEditTime: 2020-12-22 23:05:34
* @LastEditTime: 2020-12-24 11:26:16
*/

@@ -19,6 +19,27 @@

TEMPLATE_NAME,
COMP_TEMPLATE_NAME,
COMP_TEMPLATE_URL,
LOGO,
} = require('./config');
const defaultOptions = {
template: 'project',
};
const supportMap = {
project: {
fullName: TEMPLATE_NAME,
url: TEMPLATE_URL,
},
middleware: {
fullName: COMP_TEMPLATE_NAME,
url: COMP_TEMPLATE_URL,
},
plugin: {
fullName: COMP_TEMPLATE_NAME,
url: COMP_TEMPLATE_URL,
},
};
const create = async (projectName, options) => {

@@ -37,12 +58,13 @@ log.info('\n Welcome to use Koatty!');

const opt = {
...{
url: TEMPLATE_URL,
fullName: TEMPLATE_NAME
}, ...options
};
const templateDir = await template.loadAndUpdateTemplate(opt.url, opt.fullName);
const opts = { ...defaultOptions, ...options };
const temp = supportMap[opts.template];
if (!temp) {
log.error(`Can't find template [${opts.template}], please check the template name, [project]、[middleware] and [plugin] is supported currently.`);
return;
}
const templateDir = await template.loadAndUpdateTemplate(temp.url, temp.fullName);
if (!templateDir) {
log.error(`Create project fail, can't find template [${opt.fullName}], please check network!`);
log.error(`Create project fail, can't find template [${temp.url}], please check network!`);
return;

@@ -59,2 +81,11 @@ }

if (opts.template === 'middleware') {
await fileSystem.rmFile(`${projectDir}/src/plugin.ts`);
await fileSystem.moveFile(`${projectDir}/src/middleware.ts`, `${projectDir}/src/index.ts`);
}
if (opts.template === 'plugin') {
await fileSystem.rmFile(`${projectDir}/src/middleware.ts`);
await fileSystem.moveFile(`${projectDir}/src/plugin.ts`, `${projectDir}/src/index.ts`);
}
replace({

@@ -61,0 +92,0 @@ regex: '<projectName>',

@@ -26,4 +26,3 @@ #!/usr/bin/env node

program.version(pkg.version).usage('[command] <options ...>')
.option('-o, --orm <value>', 'used orm module (thinkorm, typeorm), default is thinkorm');
program.version(pkg.version).usage('[command] <options ...>');

@@ -133,4 +132,5 @@

.description('add model class')
.action((modelName) => {
require('./command/create_module')(modelName, 'model', { orm: program.orm });
.option('-o, --orm <orm>', 'used orm module (thinkorm, typeorm), default is thinkorm')
.action((modelName, cmdObj) => {
require('./command/create_module')(modelName, 'model', cleanArgs(cmdObj));
});

@@ -140,4 +140,5 @@ program

.description('add model class')
.action((modelName) => {
require('./command/create_module')(modelName, 'model', { orm: program.orm });
.option('-o, --orm <orm>', 'used orm module (thinkorm, typeorm), default is thinkorm')
.action((modelName, cmdObj) => {
require('./command/create_module')(modelName, 'model', cleanArgs(cmdObj));
});

@@ -144,0 +145,0 @@

@@ -5,3 +5,3 @@ /*

* @LastEditors: Please set LastEditors
* @LastEditTime: 2020-12-22 20:26:03
* @LastEditTime: 2020-12-24 11:25:36
* @License: BSD (3-Clause)

@@ -11,2 +11,3 @@ * @Copyright (c) - <richenlin(at)gmail.com>

const fs = require('fs');
const log = require('../utils/log');
const { exec } = require('child_process');

@@ -43,1 +44,32 @@

});
/**
* move file
* @param {string} source file source path
* @param {string} dest file destination
*/
exports.moveFile = (source, dest) => new Promise((resolve) => {
exec(`mv ${source} ${dest}`, (err) => {
if (err) {
log.error(err.message);
resolve(false);
} else {
resolve(true);
}
});
});
/**
* rm file
* @param {string} dest file destination
*/
exports.rmFile = (dest) => new Promise((resolve) => {
exec(`rm -f ${dest}`, (err) => {
if (err) {
log.error(err.message);
resolve(false);
} else {
resolve(true);
}
});
});

@@ -5,3 +5,3 @@ /*

* @LastEditors: Please set LastEditors
* @LastEditTime: 2020-12-22 19:36:40
* @LastEditTime: 2020-12-24 11:19:08
* @License: BSD (3-Clause)

@@ -8,0 +8,0 @@ * @Copyright (c) - <richenlin(at)gmail.com>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc