create-nocobase-app
Advanced tools
Comparing version 0.5.0-alpha.20 to 0.5.0-alpha.21
@@ -40,2 +40,8 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
@@ -46,2 +52,11 @@ | ||
class AppGenerator extends _utils().Generator { | ||
constructor(...args) { | ||
super(...args); | ||
this.tplContext = {}; | ||
} | ||
setTplContext(context) { | ||
this.tplContext = context; | ||
} | ||
writing() { | ||
@@ -52,6 +67,6 @@ var _this = this; | ||
_this.copyDirectory({ | ||
context: { | ||
context: _objectSpread({ | ||
version: require('../../package').version, | ||
conventionRoutes: _this.args.conventionRoutes | ||
}, | ||
}, _this.tplContext), | ||
path: (0, _path().join)(__dirname, '../../templates/AppGenerator'), | ||
@@ -58,0 +73,0 @@ target: _this.cwd |
147
lib/cli.js
@@ -23,6 +23,6 @@ "use strict"; | ||
function _fs() { | ||
const data = require("fs"); | ||
function _commander() { | ||
const data = _interopRequireDefault(require("commander")); | ||
_fs = function _fs() { | ||
_commander = function _commander() { | ||
return data; | ||
@@ -35,3 +35,3 @@ }; | ||
function _path() { | ||
const data = require("path"); | ||
const data = _interopRequireDefault(require("path")); | ||
@@ -45,30 +45,125 @@ _path = function _path() { | ||
function _ora() { | ||
const data = _interopRequireDefault(require("ora")); | ||
_ora = function _ora() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _utils2 = require("./utils"); | ||
function _execa() { | ||
const data = _interopRequireDefault(require("execa")); | ||
_execa = function _execa() { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const args = (0, _utils().yParser)(process.argv.slice(2), { | ||
alias: { | ||
version: ['v'], | ||
help: ['h'] | ||
}, | ||
boolean: ['version'] | ||
}); | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
if (args.version && !args._[0]) { | ||
args._[0] = 'version'; | ||
const local = (0, _fs().existsSync)((0, _path().join)(__dirname, '../.local')) ? _utils().chalk.cyan('@local') : ''; | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
const _require = require('../package.json'), | ||
name = _require.name, | ||
version = _require.version; | ||
const packageJson = require('../package.json'); | ||
console.log(`${name}@${version}${local}`); | ||
} else { | ||
require('./').default({ | ||
cwd: process.cwd(), | ||
args | ||
}).catch(err => { | ||
console.error(`Create failed, ${err.message}`); | ||
console.error(err); | ||
const program = new (_commander().default.Command)(packageJson.name).version(packageJson.version).option('--simple', 'create nocobase app without install dependencies').option('--quickstart', 'create quickstart nocobase app').arguments('<project-directory>').usage(`${_utils().chalk.green('<project-directory>')}`).action( /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator(function* (directory, options) { | ||
var _runner$stdout, _runner$stderr; | ||
console.log(`Creating a new Nocobase application at ${_utils().chalk.green(directory)}.`); | ||
console.log('Creating files.'); | ||
const fullPath = _path().default.join(process.cwd(), directory); | ||
yield require('./index').default({ | ||
cwd: fullPath, | ||
args: {}, | ||
tplContext: options.quickstart ? { | ||
quickstart: true | ||
} : { | ||
quickstart: false | ||
} | ||
}); | ||
const cmd = _utils().chalk.cyan((0, _utils2.hasYarn)() ? 'yarn' : 'npm run'); | ||
if (options.simple) { | ||
console.log(); | ||
console.log('Done. You can start by doing:'); | ||
console.log(); | ||
console.log(` ${_utils().chalk.cyan('cd')} ${directory}`); | ||
console.log(` ${cmd} install`); | ||
console.log(` ${cmd} nocobase init --import-demo`); | ||
console.log(` ${cmd} start`); | ||
console.log(); | ||
return; | ||
} | ||
const installPrefix = _utils().chalk.yellow('Installing dependencies:'); | ||
const loader = (0, _ora().default)(installPrefix).start(); | ||
const logInstall = (chunk = '') => { | ||
loader.text = `${installPrefix} ${chunk.toString().split('\n').join(' ')}`; | ||
}; | ||
const runner = (0, _utils2.runInstall)(fullPath); | ||
runner === null || runner === void 0 ? void 0 : (_runner$stdout = runner.stdout) === null || _runner$stdout === void 0 ? void 0 : _runner$stdout.on('data', logInstall); | ||
runner === null || runner === void 0 ? void 0 : (_runner$stderr = runner.stderr) === null || _runner$stderr === void 0 ? void 0 : _runner$stderr.on('data', logInstall); | ||
yield runner; | ||
loader.stop(); | ||
console.log(`Dependencies installed ${_utils().chalk.green('successfully')}.`); | ||
console.log(); | ||
console.log(`Your application was created at ${_utils().chalk.green(directory)}.\n`); | ||
if (options.quickstart) { | ||
// Using Sqlite as Database | ||
const prefix = _utils().chalk.yellow('Nocobase init'); | ||
const initLoader = (0, _ora().default)(prefix).start(); | ||
try { | ||
const initLog = (chunk = '') => { | ||
initLoader.text = `${prefix} ${chunk.toString().split('\n').join(' ')}`; | ||
}; | ||
const init = (0, _utils2.runInit)(fullPath); | ||
init.stderr.on('data', initLog); | ||
init.stdout.on('data', initLog); | ||
yield init; | ||
initLoader.stop(); | ||
} catch (e) { | ||
initLoader.stop(); | ||
console.log(); | ||
console.log(e.message); | ||
process.exit(1); | ||
} | ||
console.log(`Running your application.`); | ||
yield (0, _execa().default)('npm', ['run', 'start'], { | ||
stdio: 'inherit', | ||
cwd: fullPath | ||
}); | ||
} else { | ||
console.log(); | ||
console.log('You can start by doing:'); | ||
console.log(); | ||
console.log(` ${_utils().chalk.cyan('cd')} ${directory}`); | ||
console.log(` ${cmd} nocobase init --import-demo`); | ||
console.log(` ${cmd} start`); | ||
console.log(); | ||
} | ||
}); | ||
} | ||
return function (_x, _x2) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}()).showHelpAfterError().parse(process.argv); | ||
//# sourceMappingURL=cli.js.map |
@@ -29,3 +29,4 @@ "use strict"; | ||
cwd, | ||
args | ||
args, | ||
tplContext | ||
}) { | ||
@@ -36,2 +37,3 @@ const generator = new _AppGenerator.default({ | ||
}); | ||
generator.setTplContext(tplContext); | ||
yield generator.run(); | ||
@@ -38,0 +40,0 @@ }); |
{ | ||
"name": "create-nocobase-app", | ||
"version": "0.5.0-alpha.20", | ||
"version": "0.5.0-alpha.21", | ||
"main": "lib/index.js", | ||
@@ -18,3 +18,6 @@ "types": "lib/index.d.ts", | ||
"dependencies": { | ||
"@umijs/utils": "3.5.17" | ||
"@umijs/utils": "3.5.17", | ||
"commander": "^8.2.0", | ||
"execa": "^5.1.1", | ||
"ora": "^5.4.1" | ||
}, | ||
@@ -24,3 +27,3 @@ "bin": { | ||
}, | ||
"gitHead": "d80c875d5e3acacf2f682c954f3b6e63c0386340" | ||
"gitHead": "181872cf075dd9e65f9f2ff0d1ff18c541e0d7cd" | ||
} |
@@ -14,8 +14,8 @@ import { defineConfig } from 'umi'; | ||
define: { | ||
'process.env.API_URL': process.env.API_URL, | ||
'process.env.API_PORT': process.env.API_PORT, | ||
'process.env.API_URL': process.env.API_URL || "http://127.0.0.1", | ||
'process.env.API_PORT': process.env.API_PORT || "13001", | ||
}, | ||
proxy: { | ||
'/api': { | ||
'target': `http://localhost:${process.env.API_PORT}/`, | ||
'target': `http://localhost:${process.env.API_PORT || "13001"}/`, | ||
'changeOrigin': true, | ||
@@ -22,0 +22,0 @@ 'pathRewrite': { '^/api': '/api' }, |
@@ -1,33 +0,8 @@ | ||
import Server from '@nocobase/server'; | ||
import path from 'path'; | ||
import Application from '@nocobase/server'; | ||
const start = Date.now(); | ||
const api = new Server({ | ||
database: { | ||
username: process.env.DB_USER, | ||
password: process.env.DB_PASSWORD, | ||
database: process.env.DB_DATABASE, | ||
host: process.env.DB_HOST, | ||
port: process.env.DB_PORT as any, | ||
dialect: process.env.DB_DIALECT as any, | ||
dialectOptions: { | ||
charset: 'utf8mb4', | ||
collate: 'utf8mb4_unicode_ci', | ||
}, | ||
pool: { | ||
max: 5, | ||
min: 0, | ||
acquire: 60000, | ||
idle: 10000, | ||
}, | ||
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false, | ||
define: {}, | ||
sync: { | ||
force: false, | ||
alter: { | ||
drop: false, | ||
}, | ||
}, | ||
}, | ||
const api = new Application({ | ||
database: require('./config/db').default, | ||
resourcer: { | ||
@@ -52,9 +27,6 @@ prefix: '/api', | ||
for (const plugin of plugins) { | ||
api.plugin( | ||
require(`${plugin}/lib/server`).default, | ||
); | ||
api.plugin(require(`${plugin}/lib/server`).default); | ||
} | ||
api.plugin( | ||
require(`@nocobase/plugin-client/lib/server`).default, { | ||
api.plugin(require(`@nocobase/plugin-client/lib/server`).default, { | ||
dist: path.resolve(process.cwd(), './dist'), | ||
@@ -66,9 +38,7 @@ importDemo: true, | ||
// @ts-ignore | ||
process.argv.push('start', '--port', process.env.API_PORT); | ||
process.argv.push('start', '--port', process.env.API_PORT || '13001'); | ||
} | ||
console.log(process.argv); | ||
api.parse(process.argv).then(() => { | ||
console.log(`Start-up time: ${(Date.now() - start) / 1000}s`); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
36232
36
636
4
+ Addedcommander@^8.2.0
+ Addedexeca@^5.1.1
+ Addedora@^5.4.1
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcli-cursor@3.1.0(transitive)
+ Addedcli-spinners@2.9.2(transitive)
+ Addedclone@1.0.4(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommander@8.3.0(transitive)
+ Addedcross-spawn@7.0.6(transitive)
+ Addeddefaults@1.0.4(transitive)
+ Addedexeca@5.1.1(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhuman-signals@2.1.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-interactive@1.0.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedis-unicode-supported@0.1.0(transitive)
+ Addedlog-symbols@4.1.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedora@5.4.1(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedrestore-cursor@3.1.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwcwidth@1.0.1(transitive)
+ Addedwhich@2.0.2(transitive)