Skip to content

Commit

Permalink
fix: Remove "type" from package.json in deployed version to support o…
Browse files Browse the repository at this point in the history
…lder versions (#117)
  • Loading branch information
lebmouse committed Aug 13, 2024
1 parent d675b49 commit 05e1c59
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/package-tag-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ jobs:
env:
TAG_NAME: ${{ steps.tag-meta.outputs.BRANCH_SLUG }}-${{ steps.tag-meta.outputs.TIME }}
run: |
rm -rf src .husky .github .storybook .prettierrc .eslint.config.js pnpm-lock.yaml vercel.json vite.config.js tsconfig.json tsconfig.build.json tsconfig.node.json
node ./tools/removePacakgeType.cjs
rm -rf tools src .husky .github .storybook .prettierrc .eslint.config.js pnpm-lock.yaml vercel.json vite.config.js tsconfig.json tsconfig.build.json tsconfig.node.json
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
CURRENT_VERSION=$(pnpm pkg get version | tr -d '"')
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"icongen": "svgr --out-dir ./src/icon/generated-default --index-template ./tools/svgrIndexTemplate.cjs -- ./src/icon/assets",
"prepare": "husky && panda codegen"
"prepare": "husky && panda codegen",
"prepublishOnly": "node tools/removePacakgeType.cjs"
},
"dependencies": {
"date-fns": "3.3.1",
Expand Down
25 changes: 25 additions & 0 deletions tools/removePacakgeType.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
// app-router로 마이그레이션하면 제거될 코드입니디.
const fs = require('fs');
const path = require('path');

const packagePath = path.resolve(__dirname, '..', 'package.json');

fs.readFile(packagePath, 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}

const packageJson = JSON.parse(data);
delete packageJson.type;

fs.writeFile(packagePath, JSON.stringify(packageJson, null, 2), 'utf8', err => {
if (err) {
console.error(err);
return;
}
console.log('The "type" key has been removed from the package.json file.');
});
});

0 comments on commit 05e1c59

Please sign in to comment.