UNPKG

@areslabs/alita

Version:

首个ReactNative转微信小程序引擎

55 lines (43 loc) 2.2 kB
#!/usr/bin/env node /** * Copyright (c) Areslabs. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ "use strict"; var path = _interopRequireWildcard(require("path")); var _getopts = _interopRequireDefault(require("getopts")); var _chalk = _interopRequireDefault(require("chalk")); var _initProject = _interopRequireDefault(require("./initProject")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const packz = require('../package.json'); const ALITA_CORE_INDEX_PATH = function () { return path.resolve(process.cwd(), 'node_modules', '@areslabs', 'alita-core', 'lib', 'index'); }; const options = (0, _getopts.default)(process.argv, { alias: { w: 'watch', v: 'version', config: 'config', dev: 'dev', // use with init typescript: 'typescript', analyzer: 'analyzer' } }); if (options.version) { console.log(packz.version); } else if (options._.includes('init')) { (0, _initProject.default)(options._, options.typescript); } else { try { require(ALITA_CORE_INDEX_PATH()); } catch (e) { console.log(_chalk.default.red('请确认目录无误!')); console.log(e); } }