chore: format all common files (#431)

This commit is contained in:
tecvan
2025-07-31 21:46:47 +08:00
committed by GitHub
parent 8136ddd82d
commit 40088b0a05
60 changed files with 658 additions and 288 deletions

View File

@@ -18,46 +18,41 @@ import type {
IPlugin,
IHooks,
IPromptsHookParams,
} from "rush-init-project-plugin";
} from 'rush-init-project-plugin';
import { readFileSync } from 'fs';
import path from 'path';
import JSON5 from '../../autoinstallers/plugins/node_modules/json5'
import JSON5 from '../../autoinstallers/plugins/node_modules/json5';
const rushJson = JSON5.parse(
readFileSync(
path.resolve(__dirname, '../../../rush.json')
).toString('utf-8')
readFileSync(path.resolve(__dirname, '../../../rush.json')).toString('utf-8'),
);
export default class SelectTeamPlugin implements IPlugin {
apply(hooks: IHooks): void {
hooks.prompts.tap("SelectTeamPlugin", (prompts: IPromptsHookParams) => {
hooks.prompts.tap('SelectTeamPlugin', (prompts: IPromptsHookParams) => {
// Leave only the prefix team-
const teamNamePrefix = /^team-/;
const choices = rushJson.allowedProjectTags.filter(
teamName => teamNamePrefix.test(teamName)
).map(
teamName => teamName.replace(teamNamePrefix, '')
);
const choices = rushJson.allowedProjectTags
.filter(teamName => teamNamePrefix.test(teamName))
.map(teamName => teamName.replace(teamNamePrefix, ''));
// Unshift an issue, causing the user to display the issue after selecting a template.
prompts.promptQueue.unshift({
type: "list",
name: "team",
message: "Select your team",
type: 'list',
name: 'team',
message: 'Select your team',
choices,
default: 0, // Default choices [0]
});
const projectFolderPrompt = prompts.promptQueue.find(
item => item.name === 'projectFolder'
item => item.name === 'projectFolder',
);
projectFolderPrompt.default = (answers) => {
projectFolderPrompt.default = answers => {
// Remove the scope from the folder name, such as @code-arch/foo - > foo
const folderDir = answers.packageName.split('/').slice(-1)[0];
return `frontend/packages/${answers.team}/${folderDir}`;
}
};
});
}
}

View File

@@ -13,12 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { ILogger } from 'rush-init-project-plugin';
// eslint-disable-next-line @infra/no-deep-relative-import
import { spawnSync } from 'child_process';
const exec = (logger: ILogger, cmd: string, args: string[]): string | undefined => {
const exec = (
logger: ILogger,
cmd: string,
args: string[],
): string | undefined => {
try {
if (!cmd) {
return undefined;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import process from 'process';
// parseArgs.ts