Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prerelease v1.0.0-alpha.10 #11

Merged
merged 3 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28445,7 +28445,7 @@ const manualCheckConsumers = async (argv) => {
auth: argv.token,
});
const packages = getPkgNameMap();
const version = getCurrentVersion();
const version = getCurrentVersion(argv);
if (packages.length === 0 || !version) {
return;
}
Expand All @@ -28467,7 +28467,7 @@ const manualCheckConsumers = async (argv) => {
};
exports.manualCheckConsumers = manualCheckConsumers;
const checkExtensions = async (argv) => {
const currentVersion = getCurrentVersion();
const currentVersion = getCurrentVersion(argv);
const extensions = getYarnLockInfo(fs_1.default.readFileSync(path_1.default.join(process.cwd(), "yarn.lock"), "utf8"));
const result = [];
for (const [name, version] of extensions) {
Expand All @@ -28487,7 +28487,7 @@ const checkConsumers = async (argv) => {
tableId: argv.extTableId,
})) || [];
const packages = argv.packages ? JSON.parse(argv.packages) : getPkgNameMap();
const version = argv.version ?? getCurrentVersion();
const version = argv.version ?? getCurrentVersion(argv);
const repos = records.reduce((acc, cur) => {
if (packages.some((v) => cur.extensions.includes(v))) {
acc.add(cur.repo);
Expand Down Expand Up @@ -28755,11 +28755,8 @@ const getPkgNameMap = () => {
const getPkgConfig = (cwd, link) => {
return JSON.parse(fs_1.default.readFileSync(path_1.default.join(cwd, link), "utf-8"));
};
const getCurrentVersion = () => {
const cwd = process.cwd();
const hasLerna = fs_1.default.existsSync(path_1.default.join(cwd, "lerna.json"));
const { version } = getPkgConfig(cwd, hasLerna ? "lerna.json" : "package.json");
return version;
const getCurrentVersion = (argv) => {
return argv.pullRequestTitle?.split(" v")?.[1] ?? "";
};
const omit = (obj, keys) => {
return Object.fromEntries(Object.entries(obj).filter(([key]) => !keys.includes(key)));
Expand Down Expand Up @@ -40936,6 +40933,7 @@ const main = async function () {
const argv = {
owner: github_1.context.payload.repository?.owner.login,
repo: github_1.context.payload.repository?.name,
pullRequestTitle: github_1.context.payload?.pull_request?.title,
token: (0, core_1.getInput)("token"),
apiKey: (0, core_1.getInput)("apiKey"),
extBaseId: (0, core_1.getInput)("airtable_ext_baseid"),
Expand Down
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const main = async function () {
const argv: Argv = {
owner: context.payload.repository?.owner.login!,
repo: context.payload.repository?.name!,
pullRequestTitle: context.payload?.pull_request?.title,
token: getInput("token"),
apiKey: getInput("apiKey"),
extBaseId: getInput("airtable_ext_baseid"),
Expand Down
17 changes: 6 additions & 11 deletions lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface Argv {
apiKey: string;
owner: string;
repo: string;
pullRequestTitle?: string;
extBaseId: string;
extTableId: string;
storeBaseId: string;
Expand Down Expand Up @@ -75,7 +76,7 @@ export const manualCheckConsumers = async (argv: Argv) => {
auth: argv.token,
});
const packages = getPkgNameMap();
const version = getCurrentVersion();
const version = getCurrentVersion(argv);
if (packages.length === 0 || !version) {
return;
}
Expand All @@ -100,7 +101,7 @@ export const manualCheckConsumers = async (argv: Argv) => {
};

export const checkExtensions = async (argv: Argv) => {
const currentVersion = getCurrentVersion();
const currentVersion = getCurrentVersion(argv);
const extensions: Map<string, string> = getYarnLockInfo(
fs.readFileSync(path.join(process.cwd(), "yarn.lock"), "utf8")
);
Expand All @@ -123,7 +124,7 @@ export const checkConsumers = async (argv: Argv) => {
tableId: argv.extTableId,
})) || [];
const packages = argv.packages ? JSON.parse(argv.packages!) : getPkgNameMap();
const version = argv.version ?? getCurrentVersion();
const version = argv.version ?? getCurrentVersion(argv);
const repos = records.reduce((acc: Set<string>, cur: ReposModel) => {
if (packages.some((v: string) => cur.extensions.includes(v))) {
acc.add(cur.repo);
Expand Down Expand Up @@ -465,14 +466,8 @@ const getPkgConfig = (cwd: string, link: string): { [key: string]: any } => {
return JSON.parse(fs.readFileSync(path.join(cwd, link), "utf-8"));
};

const getCurrentVersion = (): string => {
const cwd = process.cwd();
const hasLerna = fs.existsSync(path.join(cwd, "lerna.json"));
const { version } = getPkgConfig(
cwd,
hasLerna ? "lerna.json" : "package.json"
);
return version;
const getCurrentVersion = (argv: Argv): string => {
return argv.pullRequestTitle?.split(" v")?.[1] ?? "";
};

const omit = (obj: { [s: string]: any }, keys: string[]) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kungfu-trader/action-sync-extensions-version",
"version": "1.0.0-alpha.9",
"version": "1.0.0-alpha.10",
"repository": "https://github.com/kungfu-trader/action-sync-extensions-version",
"author": "Kungfu",
"license": "Apache-2.0",
Expand Down