Skip to content

Commit

Permalink
feat: update github action
Browse files Browse the repository at this point in the history
  • Loading branch information
wilson-ang committed Nov 5, 2024
1 parent d06a65a commit 592aafe
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 40 deletions.
4 changes: 2 additions & 2 deletions dist/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildClient = exports.action = void 0;
exports.buildClient = void 0;
exports.action = action;
const core = __importStar(require("@actions/core"));
const github = __importStar(require("@actions/github"));
const asana_action_1 = require("./asana/asana-action");
Expand Down Expand Up @@ -246,4 +247,3 @@ function action() {
}
});
}
exports.action = action;
15 changes: 7 additions & 8 deletions dist/asana/asana-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateTask = exports.updateSection = exports.moveSection = exports.migrateSection = exports.findComment = exports.buildClient = exports.addComment = void 0;
exports.addComment = addComment;
exports.buildClient = buildClient;
exports.findComment = findComment;
exports.migrateSection = migrateSection;
exports.moveSection = moveSection;
exports.updateSection = updateSection;
exports.updateTask = updateTask;
const core = __importStar(require("@actions/core"));
const asana = __importStar(require("asana"));
// types not working asana
Expand All @@ -57,7 +63,6 @@ function moveSection(client, taskId, targets) {
}
});
}
exports.moveSection = moveSection;
function updateTask(client, taskId, targets) {
return __awaiter(this, void 0, void 0, function* () {
const task = yield client.tasks.findById(taskId);
Expand All @@ -75,7 +80,6 @@ function updateTask(client, taskId, targets) {
}
});
}
exports.updateTask = updateTask;
function updateSection(client, targets) {
return __awaiter(this, void 0, void 0, function* () {
for (const target of targets) {
Expand Down Expand Up @@ -110,7 +114,6 @@ function updateSection(client, targets) {
}
});
}
exports.updateSection = updateSection;
function migrateSection(client, targets) {
return __awaiter(this, void 0, void 0, function* () {
for (const target of targets) {
Expand All @@ -137,7 +140,6 @@ function migrateSection(client, targets) {
}
});
}
exports.migrateSection = migrateSection;
function findComment(client, taskId, commentId) {
return __awaiter(this, void 0, void 0, function* () {
let stories;
Expand All @@ -152,7 +154,6 @@ function findComment(client, taskId, commentId) {
return stories.find((story) => story.text.indexOf(commentId) !== -1);
});
}
exports.findComment = findComment;
function addComment(client, taskId, commentId, text, isPinned) {
return __awaiter(this, void 0, void 0, function* () {
if (commentId) {
Expand All @@ -171,7 +172,6 @@ function addComment(client, taskId, commentId, text, isPinned) {
}
});
}
exports.addComment = addComment;
function buildClient(asanaPAT) {
return __awaiter(this, void 0, void 0, function* () {
return asana.Client.create({
Expand All @@ -183,4 +183,3 @@ function buildClient(asanaPAT) {
.authorize();
});
}
exports.buildClient = buildClient;
7 changes: 3 additions & 4 deletions dist/shopify/check-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkTheme = void 0;
exports.checkTheme = checkTheme;
const exec_1 = require("@actions/exec");
function checkTheme(root, shopifyExecutable = "shopify", devPreview = true, flags = "") {
return __awaiter(this, void 0, void 0, function* () {
function checkTheme(root_1) {
return __awaiter(this, arguments, void 0, function* (root, shopifyExecutable = "shopify", devPreview = true, flags = "") {
const { exitCode, stdout, stderr } = yield (0, exec_1.getExecOutput)(shopifyExecutable, [
"theme",
"check",
Expand All @@ -31,4 +31,3 @@ function checkTheme(root, shopifyExecutable = "shopify", devPreview = true, flag
};
});
}
exports.checkTheme = checkTheme;
3 changes: 1 addition & 2 deletions dist/shopify/delete-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteTheme = void 0;
exports.deleteTheme = deleteTheme;
const node_fetch_1 = __importDefault(require("node-fetch"));
const get_theme_1 = require("./get-theme");
function deleteTheme(themeName, shopifyAuth) {
Expand All @@ -39,4 +39,3 @@ function deleteTheme(themeName, shopifyAuth) {
return data;
});
}
exports.deleteTheme = deleteTheme;
9 changes: 4 additions & 5 deletions dist/shopify/deploy-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.deployTheme = void 0;
exports.deployTheme = deployTheme;
const exec_1 = require("@actions/exec");
/**
* Deploy a Shopify theme to the specified store.
Expand All @@ -22,13 +22,13 @@ const exec_1 = require("@actions/exec");
* @param flags Additional flags as a single string, will be split into an array.
* @returns A promise resolving to an object with the exit code and parsed JSON output from the command.
*/
function deployTheme(root, shopifyExecutable = "shopify", themeName, password, store, devPreview = false, flags = "") {
return __awaiter(this, void 0, void 0, function* () {
function deployTheme(root_1) {
return __awaiter(this, arguments, void 0, function* (root, shopifyExecutable = "shopify", themeName, password, store, devPreview = false, flags = "") {
const commandArgs = [
"theme",
"push",
devPreview ? "--development" : undefined,
"--json",
"--json", // Ensures JSON output for parsing
...flags.split(" "),
"--path",
root,
Expand All @@ -53,4 +53,3 @@ function deployTheme(root, shopifyExecutable = "shopify", themeName, password, s
};
});
}
exports.deployTheme = deployTheme;
3 changes: 1 addition & 2 deletions dist/shopify/install-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.installCli = void 0;
exports.installCli = installCli;
const exec_1 = require("@actions/exec");
const semver_1 = __importDefault(require("semver"));
const MIN_VERSION = "3.50.0";
Expand All @@ -32,7 +32,6 @@ function installCli(version) {
].filter(Boolean));
});
}
exports.installCli = installCli;
function shouldIncludeTheme(version) {
if (!version || version.includes("experimental")) {
return false;
Expand Down
9 changes: 4 additions & 5 deletions dist/shopify/shopify.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeTheme = exports.updateTheme = exports.runCheckTheme = exports.createTheme = void 0;
exports.createTheme = createTheme;
exports.runCheckTheme = runCheckTheme;
exports.updateTheme = updateTheme;
exports.removeTheme = removeTheme;
const check_theme_1 = require("./check-theme");
const delete_theme_1 = require("./delete-theme");
const deploy_theme_1 = require("./deploy-theme");
Expand All @@ -34,7 +37,6 @@ function createTheme(shopifyAuth) {
}
});
}
exports.createTheme = createTheme;
// Function to check theme
function runCheckTheme() {
return __awaiter(this, void 0, void 0, function* () {
Expand All @@ -48,7 +50,6 @@ function runCheckTheme() {
}
});
}
exports.runCheckTheme = runCheckTheme;
// Function to update an existing theme
function updateTheme(shopifyAuth) {
return __awaiter(this, void 0, void 0, function* () {
Expand All @@ -65,7 +66,6 @@ function updateTheme(shopifyAuth) {
}
});
}
exports.updateTheme = updateTheme;
// Function to remove a theme
function removeTheme(shopifyAuth) {
return __awaiter(this, void 0, void 0, function* () {
Expand All @@ -80,4 +80,3 @@ function removeTheme(shopifyAuth) {
}
});
}
exports.removeTheme = removeTheme;
10 changes: 6 additions & 4 deletions dist/vercel/get-vercel-preview-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ const getVercelPreviewURL = (githubContext, octokit) => __awaiter(void 0, void 0
const vercelComment = comments.find((comment) => {
var _a, _b;
return ((_a = comment.user) === null || _a === void 0 ? void 0 : _a.login) === "vercel[bot]" &&
((_b = comment.body) === null || _b === void 0 ? void 0 : _b.includes("via=pr-comment-visit-preview-link&passThrough=1"));
((_b = comment.body) === null || _b === void 0 ? void 0 : _b.includes("nextjs-commerce-git"));
});
if (!vercelComment) {
console.info("No Vercel preview comment found.");
return null;
}
const vercelPreviewUrlMatch = (_b = vercelComment.body) === null || _b === void 0 ? void 0 : _b.match(/https:\/\/vercel\.live\/open-feedback\/[^?\s]+\?via=pr-comment-visit-preview-link&passThrough=1/);
const vercelPreviewUrlMatch = (_b = vercelComment.body) === null || _b === void 0 ? void 0 : _b.match(/https:\/\/nextjs-commerce-git[^?\s]+\.vercel\.app/);
if (!vercelPreviewUrlMatch) {
console.info("No Vercel preview URL found in the comment.");
return null;
}
const cleanVercelPreviewUrl = `https://${vercelPreviewUrlMatch[0].split("open-feedback/")[1].split("?")[0]}`;
return cleanVercelPreviewUrl;
// const cleanVercelPreviewUrl = `https://${
// vercelPreviewUrlMatch[0].split("open-feedback/")[1].split("?")[0]
// }`;
return vercelPreviewUrlMatch[0];
}
catch (error) {
console.error("Error fetching Vercel preview URL:", error);
Expand Down
14 changes: 6 additions & 8 deletions src/vercel/get-vercel-preview-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export const getVercelPreviewURL = async (
const vercelComment = comments.find(
(comment) =>
comment.user?.login === "vercel[bot]" &&
comment.body?.includes(
"via=pr-comment-visit-preview-link&passThrough=1"
)
comment.body?.includes("nextjs-commerce-git")
);

if (!vercelComment) {
Expand All @@ -36,19 +34,19 @@ export const getVercelPreviewURL = async (
}

const vercelPreviewUrlMatch = vercelComment.body?.match(
/https:\/\/vercel\.live\/open-feedback\/[^?\s]+\?via=pr-comment-visit-preview-link&passThrough=1/
/https:\/\/nextjs-commerce-git[^?\s]+\.vercel\.app/
);

if (!vercelPreviewUrlMatch) {
console.info("No Vercel preview URL found in the comment.");
return null;
}

const cleanVercelPreviewUrl = `https://${
vercelPreviewUrlMatch[0].split("open-feedback/")[1].split("?")[0]
}`;
// const cleanVercelPreviewUrl = `https://${
// vercelPreviewUrlMatch[0].split("open-feedback/")[1].split("?")[0]
// }`;

return cleanVercelPreviewUrl;
return vercelPreviewUrlMatch[0];
} catch (error) {
console.error("Error fetching Vercel preview URL:", error);
return null;
Expand Down

0 comments on commit 592aafe

Please sign in to comment.