Skip to content

Commit

Permalink
fixRepo handles vite.config.js too
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-skam committed Nov 7, 2023
1 parent a272541 commit c41f1f5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
1 change: 1 addition & 0 deletions .env.SAMPLE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NPM_CONFIG_TOKEN=npm_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm i
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ dist-ssr

# aider
.aider*

# Secrets
.env
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "@new-objects/cli",
"description": "Create new objects from templates.",
"private": true,
"version": "0.0.7",
"version": "0.0.8",
"main": "./src/index.js",
"bin": {
"nobj": "src/index.js"
Expand Down
24 changes: 10 additions & 14 deletions src/fixRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ import { readFile, writeFile, rm } from 'node:fs/promises';
import { $ } from 'execa';
import { settings } from './settings.js';

const filesToBeFixed = [`vite.config.js`, `package.json`];

export async function fixRepo() {
// fix name property in package.json
const packageJson = await readFile(
`${settings.projectName}/package.json`,
'utf-8',
);
const newPackageJson = packageJson.replace(
/"name": "template-[^"]+"/,
`"name": "${settings.projectName}"`,
);
await writeFile(
`${settings.projectName}/package.json`,
newPackageJson,
'utf-8',
);
for (const f of filesToBeFixed) {
const fileContent = await readFile(`${settings.projectName}/${f}`, 'utf-8');
const newFileContent = fileContent.replace(
/template-[^"/]+/g,
settings.projectName,
);
await writeFile(`${settings.projectName}/${f}`, newFileContent, 'utf-8');
}
// fix git
const $$ = $({ cwd: `${settings.projectName}` });
try {
Expand Down

0 comments on commit c41f1f5

Please sign in to comment.