Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Installation
if (isTestOrDebug) {
pkg.devDependencies = pkg.devDependencies || {}
pkg.devDependencies[packageName] = await getPackageTaggedVersion(packageName).then(version => version && `^${version}`) || 'latest'
writePkg(cwd, pkg)
} else if ((!alreadyInPkg || cliOptions.forceInstall) && !cliOptions.noInstall) {
await shouldCommitState(`[nodepack] before add ${packageName}`, true)
consola.log('')
consola.log(`๐ฆ Installing ${chalk.cyan(packageName)}...`)
consola.log('')
const packageManager = loadGlobalOptions().packageManager || getPkgCommand(cwd)
await installPackage(cwd, packageManager, cliOptions.registry, packageName)
consola.log(`${chalk.green('โ')} Successfully installed plugin: ${chalk.cyan(packageName)}`)
consola.log('')
}
if (!alreadyInPkg) {
plugins.push(packageName)
}
if (!plugins.includes(packageName)) {
consola.error(`${packageName} is not installed, can't continue the installation`)
process.exit(1)
}
},
after: async ({ shouldCommitState }) => {
if (shouldInitGit) {
const { success } = await commitOnGit(cwd, cliOptions, isTestOrDebug, `[nodepack] create project`)
gitCommitSuccess = success
}
stopSpinner()
// save preset
if (this.isPresetManual) {
await this.askSavePreset(finalPreset)
}
// log instructions
if (!cliOptions.skipGetStarted) {
consola.log('')
consola.success(`๐ Successfully created project ${chalk.yellow(projectName)}.`)
consola.log(
`๐ Get started with the following commands:\n\n` +
(cwd === process.cwd() ? `` : chalk.cyan(` ${chalk.gray('$')} cd ${projectName}\n`)) +
chalk.cyan(` ${chalk.gray('$')} nodepack`),
)
consola.log('')
}
if (!gitCommitSuccess) {
consola.warn(
`Skipped git commit due to missing username and email in git config.\n` +
`You will need to perform the initial commit yourself.\n`,
)
}
},
},
app.listen(app.get('port'), () => {
consola.ready({
message: 'Web',
badge: true
});
// Log infomation after everything is started.
consola.log('----------------------------------------');
consola.info(`Environment: ${app.get('env')}`);
consola.info(`Base URL: http://localhost:${app.get('port')}`);
consola.log('----------------------------------------');
});
});
test('Module adds plugin correctly', (t) => {
consola.log('Testing with moduleOptions:', modOptions)
return new Promise((resolve) => {
const simpleNuxt = {
addPlugin({ src, fileName, options }) {
t.is(src, path.resolve(srcDir, 'io/plugin.js'))
t.is(fileName, 'nuxt-socket-io.js')
t.truthy(options.sockets)
t.true(options.sockets.length > 0)
options.sockets.forEach((s, idx) => {
Object.entries(s).forEach(([key, entry]) => {
t.is(entry, modOptions.io.sockets[idx][key])
})
})
resolve()
},
options: {
srcDir,
hook('build:done', () => {
consola.log('Compiled successfully')
})
hook('listen', (server, { port, host }) => {
async displayNotices () {
if (this.notices.length) {
this.notices.forEach(({ pluginId, message, type }) => {
const shortId = toShortPluginId(pluginId)
const logFn = logTypes[type]
if (!logFn) {
consola.error(`Invalid api.addNotice type '${type}'.`, shortId)
} else {
const tag = message ? shortId : null
logFn(message, tag)
}
})
consola.log('')
}
}
}
logChanged ({ event, path }) {
const { icon, color, action } = eventsMapping[event] || eventsMapping.change
consola.log({
type: event,
icon: chalk[color].bold(icon),
message: `${action} ${chalk.cyan(formatPath(path))}`
})
},
async buildFragments (entryNames) {
if (this.fragmentsBuilt || this.skipBuild) return
consola.log(`๐จ๏ธ Building fragments ${chalk.blue(entryNames.join(', '))}...`)
try {
const io = process.env.NODEPACK_DEBUG === 'true' ? 'inherit' : 'ignore'
const result = await execa('nodepack-service', [
'build',
'--silent',
'--no-autoNodeEnv',
'--no-preInstall',
], {
cwd: this.cwd,
env: {
NODEPACK_ENTRIES: entryNames.join(','),
NODEPACK_NO_MAINTENANCE: 'true',
NODEPACK_OUTPUT: '.nodepack/temp/fragments/',
NODEPACK_RAW_STATS: 'true',
NODEPACK_MAINTENANCE_FRAGMENTS: 'true',
export function startStep (step: string): void {
endStep()
consola.log(dash + step + dash)
_step = step
_stepStartTime = process.hrtime()
}