add public fix and pnpm init asst
This commit is contained in:
@@ -167,7 +167,7 @@ const rvm = new Command('registry')
|
||||
.option('-s, --set <registry>', 'set registry')
|
||||
.action(async (opts) => {
|
||||
const config = getConfig();
|
||||
const defaultRegistry = ['https://kevisual.cn', 'https://kevisual.silkyai.cn', 'https://kevisual.xiongxiao.me'];
|
||||
const defaultRegistry = ['https://kevisual.cn', 'https://kevisual.silkyai.cn', 'https://kevisual.xiongxiao.me', 'http://localhost:4005'];
|
||||
if (opts.list) {
|
||||
showList(defaultRegistry);
|
||||
return;
|
||||
@@ -208,6 +208,14 @@ const xiongxiao = new Command('me').description('xiongxiao registry').action(asy
|
||||
showList(defaultRegistry);
|
||||
});
|
||||
baseURL.addCommand(xiongxiao);
|
||||
const local = new Command('local').description('local registry').action(async (opts) => {
|
||||
console.log('local registry');
|
||||
const config = getConfig();
|
||||
const defaultRegistry = ['http://localhost:4005'];
|
||||
writeConfig({ ...config, baseURL: defaultRegistry[0] });
|
||||
showList(defaultRegistry);
|
||||
});
|
||||
baseURL.addCommand(local);
|
||||
|
||||
const kv = new Command('kevisual').description('kevisual registry').action(async (opts) => {
|
||||
console.log('kevisual registry');
|
||||
|
||||
@@ -205,7 +205,7 @@ export const pack = async (opts: { isTar: boolean; packDist?: string }) => {
|
||||
const readmeContent = fs.readFileSync(readme, 'utf-8');
|
||||
collection.readme = readmeContent;
|
||||
}
|
||||
return { collection, outputFilePath };
|
||||
return { collection, outputFilePath, dir: cwd };
|
||||
};
|
||||
export const getPackageInfo = async () => {
|
||||
const cwd = process.cwd();
|
||||
@@ -287,14 +287,22 @@ export const packByIgnore = async (opts: PackByIgnoreOpts) => {
|
||||
const readmeContent = fs.readFileSync(readme, 'utf-8');
|
||||
collection.readme = readmeContent;
|
||||
}
|
||||
return { collection, outputFilePath };
|
||||
return { collection, outputFilePath, dir: cwd };
|
||||
};
|
||||
/**
|
||||
* 打包应用
|
||||
* @param ignore 是否忽略 .npmignore 文件
|
||||
* @returns 打包结果
|
||||
*/
|
||||
export const packLib = async ({ ignore = false, tar = false, packDist = 'pack-dist' }: { ignore?: boolean; tar?: boolean; packDist?: string }) => {
|
||||
export const packLib = async ({
|
||||
ignore = false,
|
||||
tar = false,
|
||||
packDist = 'pack-dist',
|
||||
}: {
|
||||
ignore?: boolean;
|
||||
tar?: boolean;
|
||||
packDist?: string;
|
||||
}): Promise<{ collection: Record<string, any>; outputFilePath: string; dir: string }> => {
|
||||
if (ignore) {
|
||||
return await packByIgnore({ isTar: tar, packDist });
|
||||
}
|
||||
@@ -367,6 +375,7 @@ const packCommand = new Command('pack')
|
||||
.option('-t, --tar', '打包为 tgz 文件')
|
||||
.option('-d, --packDist <dist>', '打包目录')
|
||||
.option('-y, --yes', '确定,直接打包', true)
|
||||
.option('-c, --clean', '清理 package.json中的 devDependencies')
|
||||
.action(async (opts) => {
|
||||
const packDist = opts.packDist || 'pack-dist';
|
||||
const packageInfo = await getPackageInfo();
|
||||
@@ -409,16 +418,20 @@ const packCommand = new Command('pack')
|
||||
]);
|
||||
appKey = answers.appKey || appKey;
|
||||
}
|
||||
let value: { collection: Record<string, any>; outputFilePath: string } = await packLib({
|
||||
let value = await packLib({
|
||||
ignore: opts.ignore,
|
||||
tar: opts.tar,
|
||||
packDist,
|
||||
});
|
||||
if (opts?.clean) {
|
||||
const newPackageJson = { ...packageInfo };
|
||||
delete newPackageJson.devDependencies;
|
||||
fs.writeFileSync(path.join(process.cwd(), 'pack-dist', 'package.json'), JSON.stringify(newPackageJson, null, 2));
|
||||
}
|
||||
if (opts.publish) {
|
||||
// 运行 deploy 命令
|
||||
const runDeployCommand = 'envision pack-deploy ' + value.outputFilePath + ' -k ' + appKey;
|
||||
const [_app, _command] = process.argv;
|
||||
console.log(chalk.blue('example: '), runDeployCommand);
|
||||
let deployDist = opts.isTar ? value.outputFilePath : packDist;
|
||||
const deployCommand = [_app, _command, 'deploy', deployDist, '-k', appKey, '-v', version, '-u'];
|
||||
if (opts.org) {
|
||||
@@ -430,6 +443,9 @@ const packCommand = new Command('pack')
|
||||
if (opts.yes) {
|
||||
deployCommand.push('-y', 'yes');
|
||||
}
|
||||
console.log(chalk.blue('deploy doing: '), deployCommand.slice(2).join(' '), '\n\n');
|
||||
console.log('pack deploy services', chalk.blue('example: '), runDeployCommand);
|
||||
|
||||
program.parse(deployCommand);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user