fix: creation apps
This commit is contained in:
parent
919759f691
commit
9bfa481731
|
@ -11,7 +11,7 @@ const {
|
|||
} = process.env;
|
||||
|
||||
module.exports = async (fleck, path) => {
|
||||
const key = [fleck].concat(path ? `.${sep}${join('packages', path, 'src')}` : []).join(':');
|
||||
const key = [fleck].concat(path ? `.${sep}${join('packages', path)}` : []).join(':');
|
||||
const ymlPath = join(FLECKS_CORE_ROOT, 'build', 'flecks.yml');
|
||||
let yml = loadYml(await readFile(ymlPath));
|
||||
yml = Object.fromEntries(Object.entries(yml).concat([[key, {}]]));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {processCode, spawnWith} from '@flecks/core/server';
|
||||
const {processCode, spawnWith} = require('@flecks/core/build/commands');
|
||||
|
||||
export default async (packageManager, cwd) => {
|
||||
module.exports = async (packageManager, cwd) => {
|
||||
const code = await processCode(spawnWith([packageManager, 'install'], {cwd}));
|
||||
if (0 !== code) {
|
||||
return code;
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import {join} from 'path';
|
||||
const {join} = require('path');
|
||||
|
||||
import {
|
||||
dumpYml,
|
||||
loadYml,
|
||||
const {
|
||||
Option,
|
||||
program,
|
||||
} = require('@flecks/core/build/commands');
|
||||
const {
|
||||
dumpYml,
|
||||
loadYml,
|
||||
transform,
|
||||
} from '@flecks/core/server';
|
||||
import validate from 'validate-npm-package-name';
|
||||
} = require('@flecks/core/server');
|
||||
const validate = require('validate-npm-package-name');
|
||||
|
||||
import build from './build';
|
||||
import move, {testDestination} from './move';
|
||||
const build = require('./build');
|
||||
const {move, testDestination} = require('./move');
|
||||
|
||||
const {
|
||||
FLECKS_CORE_ROOT = process.cwd(),
|
||||
|
@ -40,15 +42,15 @@ const {
|
|||
error.code = 129;
|
||||
throw error;
|
||||
}
|
||||
const fileTree = await move(name, join(__dirname, 'template'));
|
||||
const fileTree = await move(name, join(__dirname, '..', 'template'));
|
||||
fileTree.pipe(
|
||||
'build/flecks.yml',
|
||||
transform((chunk, encoding, done, stream) => {
|
||||
const yml = loadYml(chunk);
|
||||
if ('npm' !== packageManager) {
|
||||
yml['@flecks/core/server'] = {packageManager};
|
||||
}
|
||||
yml['@flecks/core'] = {id: app};
|
||||
if ('npm' !== packageManager) {
|
||||
yml['@flecks/core'].packageManager = packageManager;
|
||||
}
|
||||
stream.push(dumpYml(yml, {forceQuotes: true, sortKeys: true}));
|
||||
done();
|
||||
}),
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {stat} from 'fs/promises';
|
||||
import {basename, dirname, join} from 'path';
|
||||
const {stat} = require('fs/promises');
|
||||
const {basename, dirname, join} = require('path');
|
||||
|
||||
import {JsonStream, transform} from '@flecks/core/server';
|
||||
const {JsonStream, transform} = require('@flecks/core/server');
|
||||
|
||||
import FileTree from './tree';
|
||||
const FileTree = require('./tree');
|
||||
|
||||
export const testDestination = async (destination) => {
|
||||
exports.testDestination = async (destination) => {
|
||||
try {
|
||||
await stat(destination);
|
||||
return false;
|
||||
|
@ -18,7 +18,7 @@ export const testDestination = async (destination) => {
|
|||
}
|
||||
};
|
||||
|
||||
export default async (name, source) => {
|
||||
exports.move = async (name, source) => {
|
||||
const fileTree = await FileTree.loadFrom(source);
|
||||
// Renamed to avoid conflicts.
|
||||
const {files} = fileTree;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {createReadStream, createWriteStream} from 'fs';
|
||||
import {mkdir, stat} from 'fs/promises';
|
||||
const {createReadStream, createWriteStream} = require('fs');
|
||||
const {mkdir, stat} = require('fs/promises');
|
||||
|
||||
import {glob} from '@flecks/core/server';
|
||||
import minimatch from 'minimatch';
|
||||
import {dirname, join} from 'path';
|
||||
const {glob} = require('@flecks/core/server');
|
||||
const minimatch = require('minimatch');
|
||||
const {dirname, join} = require('path');
|
||||
|
||||
export default class FileTree {
|
||||
module.exports = class FileTree {
|
||||
|
||||
constructor(files = {}) {
|
||||
this.files = files;
|
||||
|
@ -63,4 +63,4 @@ export default class FileTree {
|
|||
);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"version": "3.0.0",
|
||||
"bin": {
|
||||
"create-app": "./cli.js"
|
||||
"create-app": "./build/cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "flecks build",
|
||||
|
@ -20,7 +20,6 @@
|
|||
"test": "flecks test"
|
||||
},
|
||||
"files": [
|
||||
"cli.js",
|
||||
"server.js",
|
||||
"template"
|
||||
],
|
||||
|
|
|
@ -4,10 +4,10 @@ const {stat} = require('fs/promises');
|
|||
const {join} = require('path');
|
||||
|
||||
const addFleckToYml = require('@flecks/core/build/add-fleck-to-yml');
|
||||
const {Server, program} = require('@flecks/core/server');
|
||||
const {program} = require('@flecks/core/build/commands');
|
||||
const Server = require('@flecks/core/build/server');
|
||||
const build = require('@flecks/create-app/build/build');
|
||||
const move = require('@flecks/create-app/build/move');
|
||||
const testDestination = require('@flecks/create-app/build/testDestination');
|
||||
const {move, testDestination} = require('@flecks/create-app/build/move');
|
||||
const {validate} = require('@flecks/create-app/server');
|
||||
|
||||
const {
|
||||
|
@ -29,7 +29,7 @@ const checkIsMonorepo = async () => {
|
|||
|
||||
const monorepoScope = async () => {
|
||||
try {
|
||||
const {name} = __non_webpack_require__(join(FLECKS_CORE_ROOT, 'package.json'));
|
||||
const {name} = require(join(FLECKS_CORE_ROOT, 'package.json'));
|
||||
const [scope] = name.split('/');
|
||||
return scope;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ const target = async (fleck) => {
|
|||
error.code = 129;
|
||||
throw error;
|
||||
}
|
||||
const fileTree = await move(name, join(__dirname, 'template'));
|
||||
const fileTree = await move(name, join(__dirname, '..', 'template'));
|
||||
// Write the tree.
|
||||
await fileTree.writeTo(destination);
|
||||
await build(packageManager, destination);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"version": "3.0.0",
|
||||
"bin": {
|
||||
"create-fleck": "./cli.js"
|
||||
"create-fleck": "./build/cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "flecks build",
|
||||
|
|
Loading…
Reference in New Issue
Block a user