-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(template): fix config template problem
- The `eject` command now creates a template file in the `templatePath` option instead of `output`. - This change was made because the `output` option is redundant with the `output` option of the `build` command, and because the `output` directory was being mixed up with templates and documentation when using `.erdiarc` files.
- Loading branch information
Showing
16 changed files
with
96 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { CE_DEFAULT_VALUE } from '#/configs/const-enum/CE_DEFAULT_VALUE'; | ||
import type { IDocumentOption } from '#/configs/interfaces/IDocumentOption'; | ||
import { betterMkdir } from '#/modules/files/betterMkdir'; | ||
import { isFalse } from 'my-easy-fp'; | ||
import { exists, getDirname, isDirectory } from 'my-node-fp'; | ||
import pathe from 'pathe'; | ||
|
||
export async function getTemplateDirPath(option: Pick<IDocumentOption, 'templatePath'>, cwd: string) { | ||
const templateDirPath = pathe.join(option.templatePath ?? pathe.join(cwd, CE_DEFAULT_VALUE.TEMPLATES_PATH)); | ||
const resolvedTemplateDirPath = pathe.resolve(templateDirPath); | ||
|
||
if (isFalse(await exists(resolvedTemplateDirPath))) { | ||
await betterMkdir(pathe.join(resolvedTemplateDirPath)); | ||
return resolvedTemplateDirPath; | ||
} | ||
|
||
if (isFalse(await isDirectory(templateDirPath))) { | ||
return pathe.resolve(await getDirname(templateDirPath)); | ||
} | ||
|
||
return pathe.resolve(templateDirPath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { CE_DEFAULT_VALUE } from '#/configs/const-enum/CE_DEFAULT_VALUE'; | ||
import { exists } from 'my-node-fp'; | ||
import pathe from 'pathe'; | ||
|
||
export async function getTemplateModulePath(templatePathParam?: string): Promise<string> { | ||
const currentFilePath = pathe.resolve(__dirname); | ||
|
||
if (templatePathParam != null) { | ||
const currentWithTemplatePath = pathe.resolve(pathe.join(currentFilePath, templatePathParam)); | ||
if (await exists(currentWithTemplatePath)) { | ||
return currentWithTemplatePath; | ||
} | ||
} | ||
|
||
const packageRootTemplatePath = pathe.resolve( | ||
pathe.join(currentFilePath, '..', '..', '..', CE_DEFAULT_VALUE.TEMPLATES_PATH), | ||
); | ||
|
||
if (await exists(packageRootTemplatePath)) { | ||
return packageRootTemplatePath; | ||
} | ||
|
||
const distTemplatePath = pathe.resolve(pathe.join(currentFilePath, '..', '..', CE_DEFAULT_VALUE.TEMPLATES_PATH)); | ||
if (await exists(distTemplatePath)) { | ||
return distTemplatePath; | ||
} | ||
|
||
throw new Error('cannot found template directory!'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.