fix: creators

This commit is contained in:
cha0s 2024-01-22 12:42:41 -06:00
parent 675aaadaed
commit c1eee58a41
10 changed files with 42 additions and 36 deletions

View File

@ -1,10 +1,10 @@
#!/usr/bin/env node
const D = require('@flecks/core/build/debug');
const {processCode} = require('@flecks/core/server');
const {Command} = require('commander');
const Build = require('./build');
const {processCode} = require('./commands');
const debug = D('@flecks/build/build/cli');
const debugSilly = debug.extend('silly');

View File

@ -2,6 +2,7 @@ const {spawn} = require('child_process');
const {join, normalize} = require('path');
const D = require('@flecks/core/build/debug');
const {processCode, spawnWith} = require('@flecks/core/server');
const {Argument, Option, program} = require('commander');
const {glob} = require('glob');
const rimraf = require('rimraf');
@ -33,7 +34,7 @@ exports.commands = (program, flecks) => {
args.push(packageManager, ['install', fleck]);
}
args.push({stdio: 'inherit'});
await exports.processCode(spawn(...args));
await processCode(spawn(...args));
await addFleckToYml(fleck);
},
},
@ -85,7 +86,7 @@ exports.commands = (program, flecks) => {
'--mode', (production && !hot) ? 'production' : 'development',
...((watch || hot) ? ['--watch'] : []),
];
return exports.spawnWith(
return spawnWith(
cmd,
{
env: {
@ -117,7 +118,7 @@ exports.commands = (program, flecks) => {
'.',
];
promises.push(new Promise((resolve, reject) => {
const child = exports.spawnWith(
const child = spawnWith(
cmd,
{
cwd,
@ -156,28 +157,6 @@ exports.commands = (program, flecks) => {
return commands;
};
exports.processCode = (child) => new Promise((resolve, reject) => {
child.on('error', reject);
child.on('exit', (code) => {
child.off('error', reject);
resolve(code);
});
});
exports.spawnWith = (cmd, opts = {}) => {
debug("spawning: '%s'", cmd.join(' '));
debugSilly('with options: %O', opts);
const child = spawn(cmd[0], cmd.slice(1), {
stdio: 'inherit',
...opts,
env: {
...process.env,
...opts.env,
},
});
return child;
};
exports.Argument = Argument;
exports.Option = Option;
exports.program = program;

View File

@ -10,6 +10,7 @@ const {
exports.hooks = {
'@flecks/build.extensions': () => ['.mjs', '.js', '.json', '.wasm'],
'@flecks/build.commands': commands,
'@flecks/build.config': async (target, config, env, argv, flecks) => {
if (flecks.get('@flecks/build.profile').includes(target)) {
config.plugins.push(
@ -45,7 +46,6 @@ exports.hooks = {
*/
'fleck.webpack.config.js',
],
'@flecks/build.commands': commands,
'@flecks/core.config': () => ({
/**
* The package manager used for tasks.

View File

@ -1,3 +1,32 @@
const {spawn} = require('child_process');
export {glob} from 'glob';
const D = require('../../build/debug');
const debug = D('@flecks/core/server');
const debugSilly = debug.extend('silly');
export {JsonStream, transform} from '../../build/stream';
export const processCode = (child) => new Promise((resolve, reject) => {
child.on('error', reject);
child.on('exit', (code) => {
child.off('error', reject);
resolve(code);
});
});
export const spawnWith = (cmd, opts = {}) => {
debug("spawning: '%s'", cmd.join(' '));
debugSilly('with options: %O', opts);
const child = spawn(cmd[0], cmd.slice(1), {
stdio: 'inherit',
...opts,
env: {
...process.env,
...opts.env,
},
});
return child;
};

View File

@ -1,4 +1,4 @@
const {processCode, spawnWith} = require('@flecks/build/build/commands');
const {processCode, spawnWith} = require('@flecks/core/server');
module.exports = async (packageManager, cwd) => {
const code = await processCode(spawnWith([packageManager, 'install'], {cwd}));

View File

@ -3,11 +3,8 @@
const {join} = require('path');
const {program} = require('@flecks/build/build/commands');
const {
dumpYml,
loadYml,
transform,
} = require('@flecks/core/server');
const {dumpYml, loadYml} = require('@flecks/build/server');
const {transform} = require('@flecks/core/server');
const validate = require('validate-npm-package-name');
const build = require('./build');

View File

@ -24,12 +24,12 @@
"template"
],
"dependencies": {
"@flecks/build": "^3.0.0",
"@flecks/core": "^3.0.0",
"minimatch": "^5.0.1",
"validate-npm-package-name": "^3.0.0"
},
"devDependencies": {
"@flecks/build": "^3.0.0",
"@flecks/fleck": "^3.0.0"
}
}

View File

@ -1,2 +1,3 @@
'@flecks/build': {}
'@flecks/core': {}
'@flecks/server': {}

View File

@ -23,11 +23,11 @@
"template"
],
"dependencies": {
"@flecks/build": "^3.0.0",
"@flecks/core": "^3.0.0",
"@flecks/create-app": "^3.0.0"
},
"devDependencies": {
"@flecks/build": "^3.0.0",
"@flecks/fleck": "^3.0.0"
}
}

View File

@ -2,8 +2,8 @@ const {stat, unlink} = require('fs/promises');
const {join} = require('path');
const Build = require('@flecks/build/build/build');
const {spawnWith} = require('@flecks/build/build/commands');
const {regexFromExtensions} = require('@flecks/build/server');
const {spawnWith} = require('@flecks/core/server');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const {