Comparing version 0.4.3 to 0.4.4-beta.0
304
bin/cli.js
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
const path = require('path') | ||
const chalk = require('chalk') | ||
const chalk2 = require('chalk') | ||
const fsExtra = require('fs-extra') | ||
@@ -32,2 +32,3 @@ const rollup = require('rollup') | ||
const chalk2__default = /*#__PURE__*/ _interopDefaultLegacy(chalk2) | ||
const consola2__default = /*#__PURE__*/ _interopDefaultLegacy(consola2) | ||
@@ -270,3 +271,3 @@ const _glob__default = /*#__PURE__*/ _interopDefaultLegacy(_glob) | ||
this.logger.error( | ||
`Could not locate a ${chalk.bold('package.json')} in ${chalk.bold( | ||
`Could not locate a ${chalk2.bold('package.json')} in ${chalk2.bold( | ||
DEFAULTS.rootDir | ||
@@ -760,4 +761,4 @@ )} or its parent directories.` | ||
return [ | ||
...binaries.map(([binary, input2]) => { | ||
return defu2__default['default']({}, options, { | ||
...binaries.map(([binary, input2]) => | ||
defu2__default['default']({}, options, { | ||
input: input2, | ||
@@ -772,3 +773,3 @@ output: __assign$1(__assign$1({}, getFilenames(binary, '', 'cjs')), { | ||
}) | ||
}), | ||
), | ||
...includeIf(input, input2 => | ||
@@ -819,2 +820,31 @@ defu2__default['default']({}, options, { | ||
} | ||
function hl(str) { | ||
return chalk2__default['default'].green(str) | ||
} | ||
function prettyPath(p, highlight = true) { | ||
p = path.relative(process.cwd(), p) | ||
return highlight ? hl(p) : p | ||
} | ||
const logRollupConfig = (pkg, config) => { | ||
config.forEach(item => { | ||
const input = | ||
typeof item.input === 'string' | ||
? prettyPath(item.input, false).padEnd(30) + ' \u2192 ' | ||
: item.input | ||
const output = Array.isArray(item.output) ? item.output : [item.output] | ||
output.forEach(out => { | ||
const outfile = | ||
(out == null ? void 0 : out.file) || | ||
((out == null ? void 0 : out.dir) ? out.dir + '/' : '') + | ||
String(out == null ? void 0 : out.entryFileNames) || | ||
'' | ||
const format = outfile.endsWith('.d.ts') | ||
? '(dts)' | ||
: (out == null ? void 0 : out.format) | ||
? `(${out.format})` | ||
: '' | ||
pkg.logger.debug(input, prettyPath(outfile), format) | ||
}) | ||
}) | ||
} | ||
@@ -860,97 +890,99 @@ var __assign$2 = Object.assign | ||
const build = (_0, ..._1) => | ||
__async$2(undefined, [_0, ..._1], function* ( | ||
pkg, | ||
{ watch: shouldWatch = false, dev = shouldWatch } = {} | ||
) { | ||
const { | ||
options: { suffix, linkedDependencies, rootDir, rollup: rollupOptions }, | ||
} = pkg | ||
const config = __assign$2( | ||
{ | ||
alias: {}, | ||
replace: {}, | ||
dev, | ||
}, | ||
rollupOptions | ||
) | ||
if (suffix) { | ||
for (const _name of linkedDependencies || []) { | ||
const name = _name + suffix | ||
config.replace[`'${_name}'`] = `'${name}'` | ||
config.alias[_name] = name | ||
__async$2( | ||
undefined, | ||
[_0, ..._1], | ||
function* (pkg, { watch: shouldWatch = false, dev = shouldWatch } = {}) { | ||
const { | ||
options: { suffix, linkedDependencies, rootDir, rollup: rollupOptions }, | ||
} = pkg | ||
const config = __assign$2( | ||
{ | ||
alias: {}, | ||
replace: {}, | ||
dev, | ||
}, | ||
rollupOptions | ||
) | ||
if (suffix) { | ||
for (const _name of linkedDependencies || []) { | ||
const name = _name + suffix | ||
config.replace[`'${_name}'`] = `'${name}'` | ||
config.alias[_name] = name | ||
} | ||
} | ||
} | ||
yield pkg.callHook('build:extend', { config }) | ||
const rollupConfig = getRollupConfig(config, pkg) | ||
yield pkg.callHook('build:extendRollup', { | ||
rollupConfig, | ||
}) | ||
if (shouldWatch) { | ||
const watcher = rollup.watch(rollupConfig) | ||
watcher.on('event', event => { | ||
switch (event.code) { | ||
case 'START': | ||
return pkg.logger.debug(`Watching ${pkg.pkg.name} for changes`) | ||
case 'BUNDLE_START': | ||
return pkg.logger.debug(`Building ${pkg.pkg.name}`) | ||
case 'BUNDLE_END': | ||
return | ||
case 'END': | ||
return pkg.logger.success(`Built ${chalk.bold(pkg.pkg.name)}`) | ||
case 'ERROR': | ||
formatError(rootDir, event.error) | ||
return pkg.logger.error(event.error) | ||
default: | ||
const _event = event | ||
return pkg.logger.info(JSON.stringify(_event)) | ||
} | ||
yield pkg.callHook('build:extend', { config }) | ||
const rollupConfig = getRollupConfig(config, pkg) | ||
yield pkg.callHook('build:extendRollup', { | ||
rollupConfig, | ||
}) | ||
} else { | ||
pkg.logger.debug(`Building ${pkg.pkg.name}`) | ||
yield runInParallel(rollupConfig, config2 => | ||
__async$2(this, null, function* () { | ||
try { | ||
const bundle = yield rollup.rollup(config2) | ||
yield runInParallel(asArray(config2.output), outputConfig => | ||
__async$2(this, null, function* () { | ||
if (!outputConfig) { | ||
pkg.logger.error('No build defined in generated config.') | ||
return | ||
} | ||
const { output } = yield bundle.write(outputConfig) | ||
const { fileName } = output[0] | ||
let size | ||
try { | ||
const filePath = outputConfig.dir | ||
? path.join(outputConfig.dir, fileName) | ||
: outputConfig.file || fileName | ||
const { size: bytes } = yield fsExtra.stat(filePath) | ||
if (bytes > 500) { | ||
size = chalk.green( | ||
' ' + | ||
chalk.bold((bytes / 1024).toFixed(1).padStart(5)) + | ||
' kB' | ||
) | ||
} else { | ||
size = chalk.green( | ||
' ' + chalk.bold(String(bytes).padStart(5)) + ' B' | ||
) | ||
} | ||
} catch (e) {} | ||
pkg.logger.success( | ||
`Built ${chalk.bold(pkg.pkg.name.padEnd(15))} ${chalk.gray( | ||
fileName.padStart(15) | ||
)}${size}` | ||
) | ||
}) | ||
) | ||
yield pkg.callHook('build:done', { bundle }) | ||
} catch (err) { | ||
const formattedError = formatError(rootDir, err) | ||
throw pkg.logger.error(formattedError) | ||
logRollupConfig(pkg, rollupConfig) | ||
if (shouldWatch) { | ||
const watcher = rollup.watch(rollupConfig) | ||
watcher.on('event', event => { | ||
switch (event.code) { | ||
case 'START': | ||
return pkg.logger.debug(`Watching ${pkg.pkg.name} for changes`) | ||
case 'BUNDLE_START': | ||
return pkg.logger.debug(`Building ${pkg.pkg.name}`) | ||
case 'BUNDLE_END': | ||
return | ||
case 'END': | ||
return pkg.logger.success(`Built ${chalk2.bold(pkg.pkg.name)}`) | ||
case 'ERROR': | ||
formatError(rootDir, event.error) | ||
return pkg.logger.error(event.error) | ||
default: | ||
const _event = event | ||
return pkg.logger.info(JSON.stringify(_event)) | ||
} | ||
}) | ||
) | ||
} else { | ||
pkg.logger.debug(`Building ${pkg.pkg.name}`) | ||
yield runInParallel(rollupConfig, config2 => | ||
__async$2(this, null, function* () { | ||
try { | ||
const bundle = yield rollup.rollup(config2) | ||
yield runInParallel(asArray(config2.output), outputConfig => | ||
__async$2(this, null, function* () { | ||
if (!outputConfig) { | ||
pkg.logger.error('No build defined in generated config.') | ||
return | ||
} | ||
const { output } = yield bundle.write(outputConfig) | ||
const { fileName } = output[0] | ||
let size | ||
try { | ||
const filePath = outputConfig.dir | ||
? path.join(outputConfig.dir, fileName) | ||
: outputConfig.file || fileName | ||
const { size: bytes } = yield fsExtra.stat(filePath) | ||
if (bytes > 500) { | ||
size = chalk2.green( | ||
' ' + | ||
chalk2.bold((bytes / 1024).toFixed(1).padStart(5)) + | ||
' kB' | ||
) | ||
} else { | ||
size = chalk2.green( | ||
' ' + chalk2.bold(String(bytes).padStart(5)) + ' B' | ||
) | ||
} | ||
} catch (e) {} | ||
pkg.logger.success( | ||
`Built ${chalk2.bold( | ||
pkg.pkg.name.padEnd(15) | ||
)} ${chalk2.gray(fileName.padStart(15))}${size}` | ||
) | ||
}) | ||
) | ||
yield pkg.callHook('build:done', { bundle }) | ||
} catch (err) { | ||
const formattedError = formatError(rootDir, err) | ||
throw pkg.logger.error(formattedError) | ||
} | ||
}) | ||
) | ||
} | ||
} | ||
}) | ||
) | ||
const formatError = (rootDir, error) => { | ||
@@ -967,3 +999,3 @@ let loc = rootDir | ||
var version = '0.4.3' | ||
var version = '0.4.4-beta.0' | ||
@@ -1117,42 +1149,46 @@ var __hasOwnProp$1 = Object.prototype.hasOwnProperty | ||
function run(_0, _1) { | ||
return __async$5(this, arguments, function* ( | ||
rootPackage, | ||
{ file, args, options: { workspaces, sequential } } | ||
) { | ||
const fullCommand = `${file} ${args.join()}`.trim() | ||
const filepath = path.resolve(process.cwd(), file) | ||
const isLocalFile = | ||
(file.endsWith('.js') || file.endsWith('.ts')) && | ||
fsExtra.existsSync(filepath) | ||
function runCommand(pkg) { | ||
try { | ||
if (isLocalFile) | ||
return pkg.execInteractive( | ||
`yarn siroc-runner ${filepath} ${args.join()}` | ||
return __async$5( | ||
this, | ||
arguments, | ||
function* ( | ||
rootPackage, | ||
{ file, args, options: { workspaces, sequential } } | ||
) { | ||
const fullCommand = `${file} ${args.join()}`.trim() | ||
const filepath = path.resolve(process.cwd(), file) | ||
const isLocalFile = | ||
(file.endsWith('.js') || file.endsWith('.ts')) && | ||
fsExtra.existsSync(filepath) | ||
function runCommand(pkg) { | ||
try { | ||
if (isLocalFile) | ||
return pkg.execInteractive( | ||
`yarn siroc-runner ${filepath} ${args.join()}` | ||
) | ||
const { stdout } = pkg.exec(fullCommand, { | ||
silent: true, | ||
}) | ||
pkg.logger.success( | ||
`Ran ${chalk2.bold(fullCommand)} in ${chalk2.bold(pkg.pkg.name)}.`, | ||
stdout ? '\n' : '', | ||
stdout ? chalk2.gray(stdout) : '' | ||
) | ||
const { stdout } = pkg.exec(fullCommand, { | ||
silent: true, | ||
}) | ||
pkg.logger.success( | ||
`Ran ${chalk.bold(fullCommand)} in ${chalk.bold(pkg.pkg.name)}.`, | ||
stdout ? '\n' : '', | ||
stdout ? chalk.gray(stdout) : '' | ||
) | ||
} catch (e) { | ||
pkg.logger.error( | ||
`Error running ${chalk.bold(fullCommand)} | ||
} catch (e) { | ||
pkg.logger.error( | ||
`Error running ${chalk2.bold(fullCommand)} | ||
`, | ||
chalk.gray(e) | ||
) | ||
chalk2.gray(e) | ||
) | ||
} | ||
} | ||
const packages = workspaces | ||
? yield rootPackage.getWorkspacePackages() | ||
: [rootPackage] | ||
if (!sequential) { | ||
runInParallel(packages, runCommand) | ||
} else { | ||
packages.forEach(runCommand) | ||
} | ||
} | ||
const packages = workspaces | ||
? yield rootPackage.getWorkspacePackages() | ||
: [rootPackage] | ||
if (!sequential) { | ||
runInParallel(packages, runCommand) | ||
} else { | ||
packages.forEach(runCommand) | ||
} | ||
}) | ||
) | ||
} | ||
@@ -1196,3 +1232,3 @@ | ||
const time2 = duration > 1e3 ? seconds + 's' : Math.round(duration) + 'ms' | ||
rootPackage.logger.success(`${name} in ${chalk.bold(time2)}`) | ||
rootPackage.logger.success(`${name} in ${chalk2.bold(time2)}`) | ||
}) | ||
@@ -1249,3 +1285,3 @@ obs.observe({ entryTypes: ['measure'] }) | ||
`${command}`, | ||
`Custom command (${chalk.bold(rootPackage.pkg.name)})` | ||
`Custom command (${chalk2.bold(rootPackage.pkg.name)})` | ||
) | ||
@@ -1252,0 +1288,0 @@ .action(() => run2(command, action)) |
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
const path = require('path') | ||
const chalk = require('chalk') | ||
const chalk2 = require('chalk') | ||
const fsExtra = require('fs-extra') | ||
@@ -31,2 +31,3 @@ const rollup = require('rollup') | ||
const chalk2__default = /*#__PURE__*/ _interopDefaultLegacy(chalk2) | ||
const consola2__default = /*#__PURE__*/ _interopDefaultLegacy(consola2) | ||
@@ -277,3 +278,3 @@ const _glob__default = /*#__PURE__*/ _interopDefaultLegacy(_glob) | ||
this.logger.error( | ||
`Could not locate a ${chalk.bold('package.json')} in ${chalk.bold( | ||
`Could not locate a ${chalk2.bold('package.json')} in ${chalk2.bold( | ||
DEFAULTS.rootDir | ||
@@ -767,4 +768,4 @@ )} or its parent directories.` | ||
return [ | ||
...binaries.map(([binary, input2]) => { | ||
return defu2__default['default']({}, options, { | ||
...binaries.map(([binary, input2]) => | ||
defu2__default['default']({}, options, { | ||
input: input2, | ||
@@ -779,3 +780,3 @@ output: __assign$1(__assign$1({}, getFilenames(binary, '', 'cjs')), { | ||
}) | ||
}), | ||
), | ||
...includeIf(input, input2 => | ||
@@ -826,2 +827,31 @@ defu2__default['default']({}, options, { | ||
} | ||
function hl(str) { | ||
return chalk2__default['default'].green(str) | ||
} | ||
function prettyPath(p, highlight = true) { | ||
p = path.relative(process.cwd(), p) | ||
return highlight ? hl(p) : p | ||
} | ||
const logRollupConfig = (pkg, config) => { | ||
config.forEach(item => { | ||
const input = | ||
typeof item.input === 'string' | ||
? prettyPath(item.input, false).padEnd(30) + ' \u2192 ' | ||
: item.input | ||
const output = Array.isArray(item.output) ? item.output : [item.output] | ||
output.forEach(out => { | ||
const outfile = | ||
(out == null ? void 0 : out.file) || | ||
((out == null ? void 0 : out.dir) ? out.dir + '/' : '') + | ||
String(out == null ? void 0 : out.entryFileNames) || | ||
'' | ||
const format = outfile.endsWith('.d.ts') | ||
? '(dts)' | ||
: (out == null ? void 0 : out.format) | ||
? `(${out.format})` | ||
: '' | ||
pkg.logger.debug(input, prettyPath(outfile), format) | ||
}) | ||
}) | ||
} | ||
@@ -867,97 +897,99 @@ var __assign$2 = Object.assign | ||
const build = (_0, ..._1) => | ||
__async$2(undefined, [_0, ..._1], function* ( | ||
pkg, | ||
{ watch: shouldWatch = false, dev = shouldWatch } = {} | ||
) { | ||
const { | ||
options: { suffix, linkedDependencies, rootDir, rollup: rollupOptions }, | ||
} = pkg | ||
const config = __assign$2( | ||
{ | ||
alias: {}, | ||
replace: {}, | ||
dev, | ||
}, | ||
rollupOptions | ||
) | ||
if (suffix) { | ||
for (const _name of linkedDependencies || []) { | ||
const name = _name + suffix | ||
config.replace[`'${_name}'`] = `'${name}'` | ||
config.alias[_name] = name | ||
__async$2( | ||
undefined, | ||
[_0, ..._1], | ||
function* (pkg, { watch: shouldWatch = false, dev = shouldWatch } = {}) { | ||
const { | ||
options: { suffix, linkedDependencies, rootDir, rollup: rollupOptions }, | ||
} = pkg | ||
const config = __assign$2( | ||
{ | ||
alias: {}, | ||
replace: {}, | ||
dev, | ||
}, | ||
rollupOptions | ||
) | ||
if (suffix) { | ||
for (const _name of linkedDependencies || []) { | ||
const name = _name + suffix | ||
config.replace[`'${_name}'`] = `'${name}'` | ||
config.alias[_name] = name | ||
} | ||
} | ||
} | ||
yield pkg.callHook('build:extend', { config }) | ||
const rollupConfig = getRollupConfig(config, pkg) | ||
yield pkg.callHook('build:extendRollup', { | ||
rollupConfig, | ||
}) | ||
if (shouldWatch) { | ||
const watcher = rollup.watch(rollupConfig) | ||
watcher.on('event', event => { | ||
switch (event.code) { | ||
case 'START': | ||
return pkg.logger.debug(`Watching ${pkg.pkg.name} for changes`) | ||
case 'BUNDLE_START': | ||
return pkg.logger.debug(`Building ${pkg.pkg.name}`) | ||
case 'BUNDLE_END': | ||
return | ||
case 'END': | ||
return pkg.logger.success(`Built ${chalk.bold(pkg.pkg.name)}`) | ||
case 'ERROR': | ||
formatError(rootDir, event.error) | ||
return pkg.logger.error(event.error) | ||
default: | ||
const _event = event | ||
return pkg.logger.info(JSON.stringify(_event)) | ||
} | ||
yield pkg.callHook('build:extend', { config }) | ||
const rollupConfig = getRollupConfig(config, pkg) | ||
yield pkg.callHook('build:extendRollup', { | ||
rollupConfig, | ||
}) | ||
} else { | ||
pkg.logger.debug(`Building ${pkg.pkg.name}`) | ||
yield runInParallel(rollupConfig, config2 => | ||
__async$2(this, null, function* () { | ||
try { | ||
const bundle = yield rollup.rollup(config2) | ||
yield runInParallel(asArray(config2.output), outputConfig => | ||
__async$2(this, null, function* () { | ||
if (!outputConfig) { | ||
pkg.logger.error('No build defined in generated config.') | ||
return | ||
} | ||
const { output } = yield bundle.write(outputConfig) | ||
const { fileName } = output[0] | ||
let size | ||
try { | ||
const filePath = outputConfig.dir | ||
? path.join(outputConfig.dir, fileName) | ||
: outputConfig.file || fileName | ||
const { size: bytes } = yield fsExtra.stat(filePath) | ||
if (bytes > 500) { | ||
size = chalk.green( | ||
' ' + | ||
chalk.bold((bytes / 1024).toFixed(1).padStart(5)) + | ||
' kB' | ||
) | ||
} else { | ||
size = chalk.green( | ||
' ' + chalk.bold(String(bytes).padStart(5)) + ' B' | ||
) | ||
} | ||
} catch (e) {} | ||
pkg.logger.success( | ||
`Built ${chalk.bold(pkg.pkg.name.padEnd(15))} ${chalk.gray( | ||
fileName.padStart(15) | ||
)}${size}` | ||
) | ||
}) | ||
) | ||
yield pkg.callHook('build:done', { bundle }) | ||
} catch (err) { | ||
const formattedError = formatError(rootDir, err) | ||
throw pkg.logger.error(formattedError) | ||
logRollupConfig(pkg, rollupConfig) | ||
if (shouldWatch) { | ||
const watcher = rollup.watch(rollupConfig) | ||
watcher.on('event', event => { | ||
switch (event.code) { | ||
case 'START': | ||
return pkg.logger.debug(`Watching ${pkg.pkg.name} for changes`) | ||
case 'BUNDLE_START': | ||
return pkg.logger.debug(`Building ${pkg.pkg.name}`) | ||
case 'BUNDLE_END': | ||
return | ||
case 'END': | ||
return pkg.logger.success(`Built ${chalk2.bold(pkg.pkg.name)}`) | ||
case 'ERROR': | ||
formatError(rootDir, event.error) | ||
return pkg.logger.error(event.error) | ||
default: | ||
const _event = event | ||
return pkg.logger.info(JSON.stringify(_event)) | ||
} | ||
}) | ||
) | ||
} else { | ||
pkg.logger.debug(`Building ${pkg.pkg.name}`) | ||
yield runInParallel(rollupConfig, config2 => | ||
__async$2(this, null, function* () { | ||
try { | ||
const bundle = yield rollup.rollup(config2) | ||
yield runInParallel(asArray(config2.output), outputConfig => | ||
__async$2(this, null, function* () { | ||
if (!outputConfig) { | ||
pkg.logger.error('No build defined in generated config.') | ||
return | ||
} | ||
const { output } = yield bundle.write(outputConfig) | ||
const { fileName } = output[0] | ||
let size | ||
try { | ||
const filePath = outputConfig.dir | ||
? path.join(outputConfig.dir, fileName) | ||
: outputConfig.file || fileName | ||
const { size: bytes } = yield fsExtra.stat(filePath) | ||
if (bytes > 500) { | ||
size = chalk2.green( | ||
' ' + | ||
chalk2.bold((bytes / 1024).toFixed(1).padStart(5)) + | ||
' kB' | ||
) | ||
} else { | ||
size = chalk2.green( | ||
' ' + chalk2.bold(String(bytes).padStart(5)) + ' B' | ||
) | ||
} | ||
} catch (e) {} | ||
pkg.logger.success( | ||
`Built ${chalk2.bold( | ||
pkg.pkg.name.padEnd(15) | ||
)} ${chalk2.gray(fileName.padStart(15))}${size}` | ||
) | ||
}) | ||
) | ||
yield pkg.callHook('build:done', { bundle }) | ||
} catch (err) { | ||
const formattedError = formatError(rootDir, err) | ||
throw pkg.logger.error(formattedError) | ||
} | ||
}) | ||
) | ||
} | ||
} | ||
}) | ||
) | ||
const formatError = (rootDir, error) => { | ||
@@ -984,2 +1016,3 @@ let loc = rootDir | ||
exports.includeIf = includeIf | ||
exports.logRollupConfig = logRollupConfig | ||
exports.removeBuildFolders = removeBuildFolders | ||
@@ -986,0 +1019,0 @@ exports.runInParallel = runInParallel |
@@ -342,2 +342,3 @@ import { Consola } from 'consola'; | ||
declare function getRollupConfig({ input, replace, alias, externals, dev, resolve: resolveOptions, plugins, esbuildOptions, ...options }: BuildConfigOptions, pkg?: Package): RollupOptions[]; | ||
declare const logRollupConfig: (pkg: Package, config: RollupOptions[]) => void; | ||
@@ -370,2 +371,2 @@ declare type Hook<T> = { | ||
export { BuildConfigOptions, BuildOptions, DefaultPackageOptions, Hook, Hooks, Package, PackageCommands, PackageHookOptions, PackageHooks, PackageJson, PackageJsonPerson, PackageOptions, Repository, RequireProperties, SirocOptions, asArray, build, defineSirocConfig, ensureUnique, getRollupConfig, glob, groupBy, includeDefinedProperties, includeIf, removeBuildFolders, runInParallel, sortObjectKeys, tryJSON, tryRequire }; | ||
export { BuildConfigOptions, BuildOptions, DefaultPackageOptions, Hook, Hooks, Package, PackageCommands, PackageHookOptions, PackageHooks, PackageJson, PackageJsonPerson, PackageOptions, Repository, RequireProperties, SirocOptions, asArray, build, defineSirocConfig, ensureUnique, getRollupConfig, glob, groupBy, includeDefinedProperties, includeIf, logRollupConfig, removeBuildFolders, runInParallel, sortObjectKeys, tryJSON, tryRequire }; |
import { extname, basename, resolve, dirname, relative, join } from 'path'; | ||
import { bold, green, gray } from 'chalk'; | ||
import chalk2, { bold, green, gray } from 'chalk'; | ||
import { readJSONSync, writeFile, chmod, existsSync, mkdirp, copy, remove, stat } from 'fs-extra'; | ||
@@ -639,14 +639,12 @@ import { watch, rollup } from 'rollup'; | ||
return [ | ||
...binaries.map(([binary, input2]) => { | ||
return defu2({}, options, { | ||
input: input2, | ||
output: __assign$1(__assign$1({}, getFilenames(binary, "", "cjs")), { | ||
preferConst: true, | ||
exports: "auto", | ||
banner: "#!/usr/bin/env node\n" | ||
}), | ||
external, | ||
plugins: getPlugins() | ||
}); | ||
}), | ||
...binaries.map(([binary, input2]) => defu2({}, options, { | ||
input: input2, | ||
output: __assign$1(__assign$1({}, getFilenames(binary, "", "cjs")), { | ||
preferConst: true, | ||
exports: "auto", | ||
banner: "#!/usr/bin/env node\n" | ||
}), | ||
external, | ||
plugins: getPlugins() | ||
})), | ||
...includeIf(input, (input2) => defu2({}, options, { | ||
@@ -689,2 +687,20 @@ input: input2, | ||
} | ||
function hl(str) { | ||
return chalk2.green(str); | ||
} | ||
function prettyPath(p, highlight = true) { | ||
p = relative(process.cwd(), p); | ||
return highlight ? hl(p) : p; | ||
} | ||
const logRollupConfig = (pkg, config) => { | ||
config.forEach((item) => { | ||
const input = typeof item.input === "string" ? prettyPath(item.input, false).padEnd(30) + " \u2192 " : item.input; | ||
const output = Array.isArray(item.output) ? item.output : [item.output]; | ||
output.forEach((out) => { | ||
const outfile = (out == null ? void 0 : out.file) || ((out == null ? void 0 : out.dir) ? out.dir + "/" : "") + String(out == null ? void 0 : out.entryFileNames) || ""; | ||
const format = outfile.endsWith(".d.ts") ? "(dts)" : (out == null ? void 0 : out.format) ? `(${out.format})` : ""; | ||
pkg.logger.debug(input, prettyPath(outfile), format); | ||
}); | ||
}); | ||
}; | ||
@@ -744,2 +760,3 @@ var __assign$2 = Object.assign; | ||
}); | ||
logRollupConfig(pkg, rollupConfig); | ||
if (shouldWatch) { | ||
@@ -809,2 +826,2 @@ const watcher = watch(rollupConfig); | ||
export { Package, asArray, build, defineSirocConfig, ensureUnique, getRollupConfig, glob, groupBy, includeDefinedProperties, includeIf, removeBuildFolders, runInParallel, sortObjectKeys, tryJSON, tryRequire }; | ||
export { Package, asArray, build, defineSirocConfig, ensureUnique, getRollupConfig, glob, groupBy, includeDefinedProperties, includeIf, logRollupConfig, removeBuildFolders, runInParallel, sortObjectKeys, tryJSON, tryRequire }; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
const path = require('path'); | ||
const chalk = require('chalk'); | ||
const chalk2 = require('chalk'); | ||
const fsExtra = require('fs-extra'); | ||
@@ -27,2 +27,3 @@ const rollup = require('rollup'); | ||
const chalk2__default = /*#__PURE__*/_interopDefaultLegacy(chalk2); | ||
const consola2__default = /*#__PURE__*/_interopDefaultLegacy(consola2); | ||
@@ -239,3 +240,3 @@ const _glob__default = /*#__PURE__*/_interopDefaultLegacy(_glob); | ||
if (this.options.rootDir === "/") { | ||
this.logger.error(`Could not locate a ${chalk.bold("package.json")} in ${chalk.bold(DEFAULTS.rootDir)} or its parent directories.`); | ||
this.logger.error(`Could not locate a ${chalk2.bold("package.json")} in ${chalk2.bold(DEFAULTS.rootDir)} or its parent directories.`); | ||
throw new Error(`Could not locate a package.json in ${DEFAULTS.rootDir} or its parent directories.`); | ||
@@ -663,14 +664,12 @@ } | ||
return [ | ||
...binaries.map(([binary, input2]) => { | ||
return defu2__default['default']({}, options, { | ||
input: input2, | ||
output: __assign$1(__assign$1({}, getFilenames(binary, "", "cjs")), { | ||
preferConst: true, | ||
exports: "auto", | ||
banner: "#!/usr/bin/env node\n" | ||
}), | ||
external, | ||
plugins: getPlugins() | ||
}); | ||
}), | ||
...binaries.map(([binary, input2]) => defu2__default['default']({}, options, { | ||
input: input2, | ||
output: __assign$1(__assign$1({}, getFilenames(binary, "", "cjs")), { | ||
preferConst: true, | ||
exports: "auto", | ||
banner: "#!/usr/bin/env node\n" | ||
}), | ||
external, | ||
plugins: getPlugins() | ||
})), | ||
...includeIf(input, (input2) => defu2__default['default']({}, options, { | ||
@@ -713,2 +712,20 @@ input: input2, | ||
} | ||
function hl(str) { | ||
return chalk2__default['default'].green(str); | ||
} | ||
function prettyPath(p, highlight = true) { | ||
p = path.relative(process.cwd(), p); | ||
return highlight ? hl(p) : p; | ||
} | ||
const logRollupConfig = (pkg, config) => { | ||
config.forEach((item) => { | ||
const input = typeof item.input === "string" ? prettyPath(item.input, false).padEnd(30) + " \u2192 " : item.input; | ||
const output = Array.isArray(item.output) ? item.output : [item.output]; | ||
output.forEach((out) => { | ||
const outfile = (out == null ? void 0 : out.file) || ((out == null ? void 0 : out.dir) ? out.dir + "/" : "") + String(out == null ? void 0 : out.entryFileNames) || ""; | ||
const format = outfile.endsWith(".d.ts") ? "(dts)" : (out == null ? void 0 : out.format) ? `(${out.format})` : ""; | ||
pkg.logger.debug(input, prettyPath(outfile), format); | ||
}); | ||
}); | ||
}; | ||
@@ -768,2 +785,3 @@ var __assign$2 = Object.assign; | ||
}); | ||
logRollupConfig(pkg, rollupConfig); | ||
if (shouldWatch) { | ||
@@ -780,3 +798,3 @@ const watcher = rollup.watch(rollupConfig); | ||
case "END": | ||
return pkg.logger.success(`Built ${chalk.bold(pkg.pkg.name)}`); | ||
return pkg.logger.success(`Built ${chalk2.bold(pkg.pkg.name)}`); | ||
case "ERROR": | ||
@@ -807,9 +825,9 @@ formatError(rootDir, event.error); | ||
if (bytes > 500) { | ||
size = chalk.green(" " + chalk.bold((bytes / 1024).toFixed(1).padStart(5)) + " kB"); | ||
size = chalk2.green(" " + chalk2.bold((bytes / 1024).toFixed(1).padStart(5)) + " kB"); | ||
} else { | ||
size = chalk.green(" " + chalk.bold(String(bytes).padStart(5)) + " B"); | ||
size = chalk2.green(" " + chalk2.bold(String(bytes).padStart(5)) + " B"); | ||
} | ||
} catch (e) { | ||
} | ||
pkg.logger.success(`Built ${chalk.bold(pkg.pkg.name.padEnd(15))} ${chalk.gray(fileName.padStart(15))}${size}`); | ||
pkg.logger.success(`Built ${chalk2.bold(pkg.pkg.name.padEnd(15))} ${chalk2.gray(fileName.padStart(15))}${size}`); | ||
})); | ||
@@ -845,2 +863,3 @@ yield pkg.callHook("build:done", {bundle}); | ||
exports.includeIf = includeIf; | ||
exports.logRollupConfig = logRollupConfig; | ||
exports.removeBuildFolders = removeBuildFolders; | ||
@@ -847,0 +866,0 @@ exports.runInParallel = runInParallel; |
{ | ||
"name": "siroc", | ||
"version": "0.4.3", | ||
"version": "0.4.4-beta.0", | ||
"description": "Zero-config build tooling for Node", | ||
@@ -62,15 +62,15 @@ "keywords": [ | ||
"glob": "^7.1.6", | ||
"jiti": "^0.1.12", | ||
"rollup": "^2.33.3", | ||
"rollup-plugin-dts": "^1.4.14", | ||
"jiti": "^0.1.17", | ||
"rollup": "^2.34.0", | ||
"rollup-plugin-dts": "^2.0.0", | ||
"rollup-plugin-esbuild": "2.5.2", | ||
"sort-package-json": "^1.46.1", | ||
"typescript": "^4.0.5", | ||
"sort-package-json": "^1.48.0", | ||
"typescript": "^4.1.2", | ||
"v8-compile-cache": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.12.3", | ||
"@babel/core": "^7.12.9", | ||
"@babel/plugin-transform-runtime": "^7.12.1", | ||
"@babel/preset-env": "^7.12.1", | ||
"@babel/preset-typescript": "^7.12.1", | ||
"@babel/preset-env": "^7.12.7", | ||
"@babel/preset-typescript": "^7.12.7", | ||
"@babel/runtime": "^7.12.5", | ||
@@ -82,9 +82,9 @@ "@release-it/conventional-changelog": "^2.0.0", | ||
"@types/jest": "^26.0.15", | ||
"@types/node": "^14.14.8", | ||
"@typescript-eslint/eslint-plugin": "^4.8.1", | ||
"@typescript-eslint/parser": "^4.8.1", | ||
"babel-loader": "^8.2.1", | ||
"@types/node": "^14.14.10", | ||
"@typescript-eslint/eslint-plugin": "^4.8.2", | ||
"@typescript-eslint/parser": "^4.8.2", | ||
"babel-loader": "^8.2.2", | ||
"codecov": "^3.8.1", | ||
"conventional-changelog-conventionalcommits": "^4.5.0", | ||
"eslint": "^7.13.0", | ||
"eslint": "^7.14.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
@@ -96,8 +96,8 @@ "eslint-plugin-jest": "^24.1.3", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.1", | ||
"prettier": "^2.1.2", | ||
"release-it": "14.2.1", | ||
"lint-staged": "^10.5.2", | ||
"prettier": "^2.2.1", | ||
"release-it": "14.2.2", | ||
"semver": "^7.3.2", | ||
"tsd": "^0.13.1", | ||
"typescript": "^4.0.5" | ||
"typescript": "^4.1.2" | ||
}, | ||
@@ -104,0 +104,0 @@ "tsd": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
156615
4293
+ Addedrollup-plugin-dts@2.0.1(transitive)
- Removedrollup-plugin-dts@1.4.14(transitive)
Updatedjiti@^0.1.17
Updatedrollup@^2.34.0
Updatedrollup-plugin-dts@^2.0.0
Updatedsort-package-json@^1.48.0
Updatedtypescript@^4.1.2