chore: remove useless templates (#330)

This commit is contained in:
tecvan
2025-07-30 17:51:07 +08:00
committed by GitHub
parent ce521dae8a
commit cacdba67cd
54 changed files with 59 additions and 1208 deletions

View File

@@ -13,8 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { IPlugin, IHooks, IPromptsHookParams } from 'rush-init-project-plugin';
import type {
IPlugin,
IHooks,
IPromptsHookParams,
} from 'rush-init-project-plugin';
// FIXME:
// 按照 https://github.com/bytemate/rush-plugins/blob/main/rush-plugins/rush-init-project-plugin/docs/init_project_configuration.md
// 一文的指引,无法正确 resolve 到对应模块,暂时没找到解决方案,故此处先用相对路径引用
@@ -24,27 +28,34 @@ import { exec } from './utils';
export default class SetDefaultAuthorPlugin implements IPlugin {
private readonly logger = createLog({
prefix: SetDefaultAuthorPlugin.name
prefix: SetDefaultAuthorPlugin.name,
});
apply(hooks: IHooks): void {
hooks.prompts.tap(SetDefaultAuthorPlugin.name, async (prompts: IPromptsHookParams) => {
const prompAuthorEmail = prompts.promptQueue.find((r) => r.name === 'authorName');
if (prompAuthorEmail) {
const userEmail = String(await exec(this.logger, 'git', ['config', '--get', 'user.email']));
Object.assign(prompAuthorEmail, {
default() {
return userEmail;
},
validate(author: string) {
return /@bytedance\.com$/.test(author);
}
});
hooks.prompts.tap(
SetDefaultAuthorPlugin.name,
async (prompts: IPromptsHookParams) => {
const prompAuthorEmail = prompts.promptQueue.find(
r => r.name === 'authorName',
);
if (prompAuthorEmail) {
const userEmail = String(
await exec(this.logger, 'git', ['config', '--get', 'user.email']),
);
Object.assign(prompAuthorEmail, {
default() {
return userEmail;
},
validate(author: string) {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(author);
},
});
hooks.answers.tap("authorPrefix", (answers) => {
answers.authorPrefix = userEmail.split('@')?.[0] ?? '';
});
}
});
hooks.answers.tap('authorPrefix', answers => {
answers.authorPrefix = userEmail.split('@')?.[0] ?? '';
});
}
},
);
}
}