Skip to content

Commit

Permalink
feat: generator modify scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JSerFeng committed Sep 20, 2023
1 parent 31bb519 commit 610a747
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path';
import { GeneratorContext, GeneratorCore } from '@modern-js/codesmith';
import { AppAPI } from '@modern-js/codesmith-api-app';
// import { JsonAPI } from '@modern-js/codesmith-api-json';
import { JsonAPI } from '@modern-js/codesmith-api-json';
import {
isTsProject,
getPackageManager,
Expand Down Expand Up @@ -132,6 +132,22 @@ const handleTemplateFile = async (
: {}),
};

const jsonAPI = new JsonAPI(generator);
await jsonAPI.update(
context.materials.default.get(path.join(appDir, './package.json')),
{
query: {},
update: {
$set: {
scripts: {
'build-storybook': 'storybook build',
storybook: 'storybook dev -p 6006',
},
},
},
},
);

await appApi.runSubGenerator(
getGeneratorPath(DependenceGenerator, context.config.distTag),
undefined,
Expand Down

0 comments on commit 610a747

Please sign in to comment.