Skip to content

Commit

Permalink
[#121] Update the package name when initialize vite template
Browse files Browse the repository at this point in the history
  • Loading branch information
bterone committed Sep 29, 2023
1 parent 458ea7a commit a77fd48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/cli-tool/src/template/initialize-vite-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import runCommand from '../helpers/child-process';
import { replaceLine } from '../helpers/file-editor';
import { CopyStrategy, DownloadStrategy } from './fetchingStrategy';

const replaceAppNameInFiles = ['package.json', 'index.html'];
const replaceAppNameInFiles = ['index.html'];
const replcaeNimbleNameInFiles = ['package.json'];

const fetchTemplateFiles = (options: InitTemplateOptions): Promise<void> => {
let fetchStrategy: CopyStrategy | DownloadStrategy;

// If passed templateReference in CLI, use the DownloadStrategy
// TODO: Decide if we want to keep DownloadStrategy long-term
if (options.templateReference && options.templateReference.trim() === '') {
fetchStrategy = new DownloadStrategy();
} else {
Expand All @@ -30,6 +32,14 @@ const replaceAppName = (options: InitTemplateOptions): void => {
options.appName,
);
});

replcaeNimbleNameInFiles.forEach((fileName) => {
replaceLine(
`${options.dest}${options.appName}/${fileName}`,
'nimble-vite-template',
options.appName,
);
});
};

const npmInstall = (options: InitTemplateOptions): Promise<void> => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-template/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vite-template",
"name": "nimble-vite-template",
"version": "0.1.0",
"private": true,
"dependencies": {
Expand Down

0 comments on commit a77fd48

Please sign in to comment.