Skip to content

Commit c357306

Browse files
committed
feat: add pub options
1 parent 30e6d8c commit c357306

3 files changed

Lines changed: 42 additions & 39 deletions

File tree

src/built-in-plugins/command-publish/plugin/interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export interface PublishOption {
44
skipLint?: boolean;
55
skipNpm?: boolean;
66
semver?: string;
7+
installAll?: boolean;
78
}

src/built-in-plugins/command-publish/plugin/run-publish.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,21 @@ export const publish = async (options: PublishOption) => {
4141
const { depMonoPackages, depMap } = await getMonoAndNpmDepsOnce();
4242

4343
if (depMonoPackages.length > 0) {
44-
const installAllPrompt = await inquirer.prompt([
45-
{
46-
message: `${pri.selectedSourceType} depends on monorepo ${depMonoPackages
47-
.map(eachPackage => `"${eachPackage.name}"`)
48-
.join(', ')} \n Do you want to publish these packages first?`,
49-
name: 'installAll',
50-
type: 'confirm',
51-
},
52-
]);
44+
let installAllPrompt = { installAll: false };
45+
46+
if (options.installAll) {
47+
installAllPrompt = { installAll: true };
48+
} else {
49+
installAllPrompt = await inquirer.prompt([
50+
{
51+
message: `${pri.selectedSourceType} depends on monorepo ${depMonoPackages
52+
.map(eachPackage => `"${eachPackage.name}"`)
53+
.join(', ')} \n Do you want to publish these packages first?`,
54+
name: 'installAll',
55+
type: 'confirm',
56+
},
57+
]);
58+
}
5359

5460
await buildDeclaration();
5561

src/built-in-plugins/project-analyse-pages/plugin/index.ts

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -137,35 +137,33 @@ pri.project.onCreateEntry((analyseInfo: IResult, entry) => {
137137

138138
entry.pipeAppComponent(async entryComponent => {
139139
return `
140-
${(
141-
await Promise.all(
142-
analyseInfo.projectAnalysePages.pages
143-
.filter(page => !!page.file)
144-
.map(async page => {
145-
const pageRequirePath = normalizePath(
146-
path.relative(path.join(pri.projectRootPath, tempPath.dir), path.join(page.file.dir, page.file.name)),
147-
);
148-
149-
const importCode = `import(/* webpackChunkName: "${
150-
page.componentName
151-
}" */ "${pageRequirePath}").then(code => {
140+
${(await Promise.all(
141+
analyseInfo.projectAnalysePages.pages
142+
.filter(page => !!page.file)
143+
.map(async page => {
144+
const pageRequirePath = normalizePath(
145+
path.relative(path.join(pri.projectRootPath, tempPath.dir), path.join(page.file.dir, page.file.name)),
146+
);
147+
148+
const importCode = `import(/* webpackChunkName: "${
149+
page.componentName
150+
}" */ "${pageRequirePath}").then(code => {
152151
const filePath = "${path.format(page.file)}"
153152
154153
${await entry.pipe.get('afterPageLoad', '')}
155154
${await entry.pipe.get('returnPageInstance', 'return code')}
156155
}),`;
157156
158-
return `
157+
return `
159158
const ${page.componentName}Lazy: any = React.lazy(() => ${importCode});
160159
const ${page.componentName}: React.FC = props => (
161160
<React.Suspense fallback={<PageLazyFallback />}>
162161
<${page.componentName}Lazy {...props} />
163162
</React.Suspense>
164163
);
165164
`;
166-
}),
167-
)
168-
).join('\n')}
165+
}),
166+
)).join('\n')}
169167
${entryComponent}
170168
`;
171169
});
@@ -185,24 +183,22 @@ pri.project.onCreateEntry((analyseInfo: IResult, entry) => {
185183

186184
entry.pipeAppRoutes(async renderRoutes => {
187185
return `
188-
${(
189-
await Promise.all(
190-
analyseInfo.projectAnalysePages.pages.map(async page => {
191-
if (page.file) {
192-
return `
186+
${(await Promise.all(
187+
analyseInfo.projectAnalysePages.pages.map(async page => {
188+
if (page.file) {
189+
return `
193190
<${await entry.pipe.get('commonRoute', 'Route')} exact path="${page.routerPath}" component={${
194-
page.componentName
195-
}} />\n
191+
page.componentName
192+
}} />\n
196193
`;
197-
}
198-
if (page.redirect) {
199-
return `
194+
}
195+
if (page.redirect) {
196+
return `
200197
<Redirect from="${page.routerPath}" to="${page.redirect}" />\n
201198
`;
202-
}
203-
}),
204-
)
205-
).join('\n')}
199+
}
200+
}),
201+
)).join('\n')}
206202
${renderRoutes}
207203
`;
208204
});

0 commit comments

Comments
 (0)