本文整理汇总了TypeScript中ora.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ora.default方法的具体用法?TypeScript ora.default怎么用?TypeScript ora.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ora
的用法示例。
在下文中一共展示了ora.default方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: prepareQuickAppEnvironment
async function prepareQuickAppEnvironment (buildData: IBuildData) {
let isReady = false
let needDownload = false
let needInstall = false
const originalOutputDir = buildData.originalOutputDir
console.log()
if (fs.existsSync(path.join(buildData.originalOutputDir, 'sign'))) {
needDownload = false
} else {
needDownload = true
}
if (needDownload) {
const getSpinner = ora('开始下载快应用运行容器...').start()
await downloadGithubRepoLatestRelease('NervJS/quickapp-container', buildData.appPath, originalOutputDir)
await unzip(path.join(originalOutputDir, 'download_temp.zip'))
getSpinner.succeed('快应用运行容器下载完成')
} else {
console.log(`${chalk.green('✔ ')} 快应用容器已经准备好`)
}
console.log()
process.chdir(originalOutputDir)
if (fs.existsSync(path.join(originalOutputDir, 'node_modules'))) {
needInstall = false
} else {
needInstall = true
}
if (needInstall) {
let command
if (shouldUseYarn()) {
command = 'NODE_ENV=development yarn install'
} else if (shouldUseCnpm()) {
command = 'NODE_ENV=development cnpm install'
} else {
command = 'NODE_ENV=development npm install'
}
const installSpinner = ora(`安装快应用依赖环境, 需要一会儿...`).start()
const install = shelljs.exec(command, { silent: true })
if (install.code === 0) {
installSpinner.color = 'green'
installSpinner.succeed('安装成功')
console.log(`${install.stderr}${install.stdout}`)
isReady = true
} else {
installSpinner.color = 'red'
installSpinner.fail(chalk.red(`快应用依赖环境安装失败,请进入 ${path.basename(originalOutputDir)} 重新安装!`))
console.log(`${install.stderr}${install.stdout}`)
isReady = false
}
} else {
console.log(`${chalk.green('✔ ')} 快应用依赖已经安装好`)
isReady = true
}
return isReady
}
示例2: return
return () => {
if (!spinner) spinner = ora(`Starting development server, please wait~`)
return spinner
}
示例3: getProjectConfig
commandObject.handler = argv => {
// load env vars from .env file
const envPath = argv['dotenv'] || '.env'
dotenv.config({ path: envPath })
// prepare context object
const context: Context = {
prompt: inquirer.createPromptModule(),
spinner: ora(),
async getProjectConfig() {
let config: GraphQLProjectConfig | undefined
while (!config) {
try {
config = argv['project']
? getGraphQLProjectConfig(process.cwd(), argv['project'])
: (getGraphQLProjectConfig(process.cwd()) as GraphQLProjectConfig)
config.config = resolveEnvsInValues(config.config, process.env)
config = await patchGraphcoolEndpointsToConfig(
config,
process.cwd(),
)
config = await patchPrismaEndpointsToConfig(config, process.cwd())
config = await patchOpenApiEndpointsToConfig(config)
} catch (error) {
const config: GraphQLConfig = getGraphQLConfig(process.cwd())
const projectNames = Object.keys(config.getProjects() || {})
if (projectNames) {
if (error.message.includes('multiproject')) {
console.log(chalk.yellow('No project name specified'))
} else if (error.message.includes('not a valid project name')) {
console.log(chalk.yellow('Invalid project name specified'))
}
const { projectName } = await inquirer.prompt({
type: 'list',
name: 'projectName',
choices: projectNames,
message: 'Select a project:',
})
argv['project'] = projectName
} else {
throw error
}
}
}
return config
},
async getConfig() {
let config = getGraphQLConfig(process.cwd())
config.config = resolveEnvsInValues(config.config, process.env)
config = await patchGraphcoolEndpointsToConfig(config)
config = await patchPrismaEndpointsToConfig(config)
config = await patchOpenApiEndpointsToConfig(config)
return config
},
}
let result = new Promise((resolve, reject) => {
try {
resolve(originalHandler(context, argv))
} catch (e) {
reject(e)
}
})
result.catch(e => {
if (context.spinner['enabled']) {
context.spinner.fail()
}
if (process.env.DEBUG === '*') {
if (e.stack) {
console.log(e.stack)
} else {
console.log(e)
}
} else {
console.log(chalk.red(e.message))
}
if (e instanceof ConfigNotFoundError) {
console.log(
chalk.yellow(
`\nRun ${chalk.green('graphql init')} to create new .graphqlconfig`,
),
)
}
process.exitCode = 1
})
}
示例4: Error
(async () => {
const electronPrebuiltPath = argv.e ? path.resolve(process.cwd(), argv.e) : locateElectronPrebuilt();
let electronPrebuiltVersion = argv.v;
if (!electronPrebuiltVersion) {
try {
if (!electronPrebuiltPath) throw new Error("electron-prebuilt not found");
const pkgJson = require(path.join(electronPrebuiltPath, 'package.json'));
electronPrebuiltVersion = pkgJson.version;
} catch (e) {
throw new Error('Unable to find electron-prebuilt\'s version number, either install it or specify an explicit version');
}
}
let rootDirectory = argv.m;
if (!rootDirectory) {
// NB: We assume here that we're going to rebuild the immediate parent's
// node modules, which might not always be the case but it's at least a
// good guess
rootDirectory = path.resolve(__dirname, '../../..');
if (!await fs.exists(rootDirectory) || !await fs.exists(path.resolve(rootDirectory, 'package.json'))) {
// Then we try the CWD
rootDirectory = process.cwd();
if (!await fs.exists(rootDirectory) || !await fs.exists(path.resolve(rootDirectory, 'package.json'))) {
throw new Error('Unable to find parent node_modules directory, specify it via --module-dir, E.g. "--module-dir ." for the current directory');
}
}
} else {
rootDirectory = path.resolve(process.cwd(), rootDirectory);
}
let modulesDone = 0;
let moduleTotal = 0;
const rebuildSpinner = ora('Searching dependency tree').start();
let lastModuleName: string;
const redraw = (moduleName?: string) => {
if (moduleName) lastModuleName = moduleName;
if (argv.p) {
rebuildSpinner.text = `Building modules: ${modulesDone}/${moduleTotal}`;
} else {
rebuildSpinner.text = `Building module: ${lastModuleName}, Completed: ${modulesDone}`;
}
}
const rebuilder = rebuild(rootDirectory, electronPrebuiltVersion, argv.a || process.arch, argv.w ? argv.w.split(',') : [], argv.f, argv.d, argv.t ? argv.t.split(',') : ['prod', 'dev'], argv.p ? 'parallel' : (argv.s ? 'sequential' : undefined));
const lifecycle = rebuilder.lifecycle;
lifecycle.on('module-found', (moduleName: string) => {
moduleTotal += 1;
redraw(moduleName);
});
lifecycle.on('module-done', () => {
modulesDone += 1;
redraw();
});
try {
await rebuilder;
} catch (err) {
rebuildSpinner.text = 'Rebuild Failed';
rebuildSpinner.fail();
throw err;
}
rebuildSpinner.text = 'Rebuild Complete';
rebuildSpinner.succeed();
})();