Fix tool when run from node_modules
Change-Id: Ica686f76a2264d760a1cd027b3393774778a6466
This commit is contained in:
parent
829249c843
commit
6f08d6cc31
2 changed files with 19 additions and 6 deletions
8
README.md
Normal file
8
README.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# Seedling
|
||||||
|
|
||||||
|
## How to start
|
||||||
|
|
||||||
|
1. Create context folder and then use it as last argument (use can use `.`)
|
||||||
|
2. Create file `.npmrc`
|
||||||
|
3. Paste this content to file `@toolkit:registry=https://npm.romanjaros.dev`
|
||||||
|
2. Use this `pnpm dlx @toolkit/seedling --name many --port 93 --monorepo T ./build`
|
17
create.js
17
create.js
|
@ -8,14 +8,16 @@ const appName = argv.name ?? 'app';
|
||||||
const appPort = argv.port ?? '0';
|
const appPort = argv.port ?? '0';
|
||||||
const isMonorepo = argv.monorepo === 'T';
|
const isMonorepo = argv.monorepo === 'T';
|
||||||
|
|
||||||
// context directory
|
const rootDir = __dirname;
|
||||||
const contextDir = `${argv._[0]}` ?? '.';
|
const contextDir = `${argv._[0]}/` ?? './';
|
||||||
|
|
||||||
// create app folder
|
// create app folder
|
||||||
const appsDir = `${contextDir}/apps`;
|
const appsDir = `${contextDir}/apps`;
|
||||||
const appDir = isMonorepo ? `${contextDir}/apps/${appName}-fe` : `${contextDir}/`;
|
const appDir = isMonorepo ? `${contextDir}/apps/${appName}-fe` : `${contextDir}/`;
|
||||||
if (!fs.existsSync(appDir)) {
|
if (!fs.existsSync(appDir)) {
|
||||||
fs.mkdirSync(contextDir);
|
if (!fs.existsSync(contextDir)) {
|
||||||
|
fs.mkdirSync(contextDir);
|
||||||
|
}
|
||||||
if (isMonorepo) {
|
if (isMonorepo) {
|
||||||
fs.mkdirSync(appsDir);
|
fs.mkdirSync(appsDir);
|
||||||
}
|
}
|
||||||
|
@ -25,11 +27,14 @@ if (!fs.existsSync(appDir)) {
|
||||||
|
|
||||||
// copy folder content
|
// copy folder content
|
||||||
try {
|
try {
|
||||||
fs.cpSync('./source/shared/', contextDir, {
|
fs.cpSync(`${rootDir}/source/shared/`, contextDir, {
|
||||||
overwrite: false,
|
force: true,
|
||||||
|
recursive: true,
|
||||||
|
});
|
||||||
|
fs.cpSync(`${rootDir}/source/app/`, appDir, {
|
||||||
|
force: true,
|
||||||
recursive: true,
|
recursive: true,
|
||||||
});
|
});
|
||||||
fs.cpSync('./source/app/', appDir, { overwrite: true, recursive: true });
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue