Skip to content

Commit 6987871

Browse files
author
月满
committed
fix: auth selected package
1 parent a022d94 commit 6987871

File tree

5 files changed

+45
-32
lines changed

5 files changed

+45
-32
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pri",
3-
"version": "4.1.5",
3+
"version": "4.1.6",
44
"types": "src/node/index.ts",
55
"main": "built/node/index.js",
66
"scripts": {

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export const publish = async (options: PublishOption) => {
3030
await pri.project.checkProjectFiles();
3131

3232
const currentSelectedSourceType = pri.selectedSourceType;
33+
const selectedPkgJson =
34+
currentSelectedSourceType === 'root'
35+
? pri.projectPackageJson
36+
: pri.packages.find(p => p.name === currentSelectedSourceType)?.packageJson;
3337

3438
if (!options.skipLint) {
3539
await pri.project.lint({
@@ -62,7 +66,8 @@ export const publish = async (options: PublishOption) => {
6266
!options.commitOnly && (await buildDeclaration());
6367

6468
if (includeAllPrompt.includeAll) {
65-
await authPublish([pri.projectPackageJson.name, ...depMonoPackages.map(v => v.packageJson.name)]);
69+
const authList = [selectedPkgJson?.name, ...depMonoPackages.map(v => v.packageJson.name)].filter(n => !!n);
70+
await authPublish(authList);
6671
for (const eachPackage of depMonoPackages) {
6772
await publishByPackageName(eachPackage.name, options, depMap, isDevelopBranch, currentBranchName);
6873
}
@@ -71,7 +76,9 @@ export const publish = async (options: PublishOption) => {
7176
// eslint-disable-next-line no-unused-expressions
7277
!options.commitOnly && (await buildDeclaration());
7378
}
74-
await authPublish([pri.projectPackageJson.name]);
79+
if (selectedPkgJson?.name) {
80+
await authPublish([selectedPkgJson.name]);
81+
}
7582
await publishByPackageName(currentSelectedSourceType, options, depMap, isDevelopBranch, currentBranchName);
7683

7784
await fs.remove(path.join(pri.projectRootPath, tempPath.dir, declarationPath.dir));

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

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

138138
entry.pipeAppComponent(async entryComponent => {
139139
return `
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 => {
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 => {
151152
const filePath = "${path.format(page.file)}"
152153
153154
${await entry.pipe.get('afterPageLoad', '')}
154155
${await entry.pipe.get('returnPageInstance', 'return code')}
155156
}),`;
156157
157-
return `
158+
return `
158159
const ${page.componentName}Lazy: any = React.lazy(() => ${importCode});
159160
const ${page.componentName}: React.FC = props => (
160161
<React.Suspense fallback={<PageLazyFallback />}>
161162
<${page.componentName}Lazy {...props} />
162163
</React.Suspense>
163164
);
164165
`;
165-
}),
166-
)).join('\n')}
166+
}),
167+
)
168+
).join('\n')}
167169
${entryComponent}
168170
`;
169171
});
@@ -183,22 +185,24 @@ pri.project.onCreateEntry((analyseInfo: IResult, entry) => {
183185

184186
entry.pipeAppRoutes(async renderRoutes => {
185187
return `
186-
${(await Promise.all(
187-
analyseInfo.projectAnalysePages.pages.map(async page => {
188-
if (page.file) {
189-
return `
188+
${(
189+
await Promise.all(
190+
analyseInfo.projectAnalysePages.pages.map(async page => {
191+
if (page.file) {
192+
return `
190193
<${await entry.pipe.get('commonRoute', 'Route')} exact path="${page.routerPath}" component={${
191-
page.componentName
192-
}} />\n
194+
page.componentName
195+
}} />\n
193196
`;
194-
}
195-
if (page.redirect) {
196-
return `
197+
}
198+
if (page.redirect) {
199+
return `
197200
<Redirect from="${page.routerPath}" to="${page.redirect}" />\n
198201
`;
199-
}
200-
}),
201-
)).join('\n')}
202+
}
203+
}),
204+
)
205+
).join('\n')}
202206
${renderRoutes}
203207
`;
204208
});

src/utils/lint.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export async function lint(options?: Partial<DefaultOptions>) {
5353

5454
let lintFiles: string[] = [];
5555
let prettierFiles: string[] = [];
56-
let lintFilesPattern: string = '';
56+
let lintFilesPattern = '';
5757

5858
if (mergedOptions.lintAll) {
5959
if (globalState.selectedSourceType === 'root') {
@@ -85,7 +85,9 @@ export async function lint(options?: Partial<DefaultOptions>) {
8585
const lintResult = await spinner(
8686
`Lint ${mergedOptions.lintAll ? 'all' : ''} ${lintFiles.length} files.`,
8787
async () => {
88-
const files = execSync(`npx prettier --ignore-path ${eslintIgnorePath} --list-different --write ${lintFilesPattern}`);
88+
const files = execSync(
89+
`npx prettier --ignore-path ${eslintIgnorePath} --list-different --write ${lintFilesPattern}`,
90+
);
8991
prettierFiles = _.compact(files.toString().split('\n'));
9092
return cli.executeOnFiles(lintFiles);
9193
},

src/utils/npm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import * as fetch from 'isomorphic-fetch';
12
import { exec } from './exec';
23
import { globalState } from './global-state';
3-
import * as fetch from 'isomorphic-fetch';
44

55
const npmWebSite = 'http://web.npm.alibaba-inc.com/package';
66

0 commit comments

Comments
 (0)