Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
tag prereleases as beta
Browse files Browse the repository at this point in the history
  • Loading branch information
SiAdcock committed Nov 9, 2020
1 parent 851b64b commit aa6bd09
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
"release:major:all": "yarn build:all && yarn validate && yarn verbump:major:all && yarn publish:release",
"release:minor:all": "yarn build:all && yarn validate && yarn verbump:minor:all && yarn publish:release",
"release:patch:all": "yarn build:all && yarn validate && yarn verbump:patch:all && yarn publish:release",
"release:prerelease:all": "yarn build:all && yarn validate && yarn publish:release",
"release:prerelease-bump:all": "yarn build:all && yarn validate && yarn verbump:prerelease:all && yarn publish:release"
"release:prerelease:all": "yarn build:all && yarn validate && yarn publish:release && yarn tag:beta:all",
"release:prerelease-bump:all": "yarn build:all && yarn validate && yarn verbump:prerelease:all && yarn publish:release && yarn tag:beta:all",
"tag:beta:all": "ts-node ./scripts/tag-beta-all"
},
"private": true,
"workspaces": [
Expand Down
54 changes: 54 additions & 0 deletions scripts/package-names.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { join } from "path"
import { readdir, stat } from "fs"
import { promisify } from "util"

const readdirP = promisify(readdir)
const statP = promisify(stat)

const coreComponents = join(__dirname, "../src/core/components")
const editorialComponents = join(__dirname, "../src/editorial/web/components")

const isDirectory = (path: string) =>
statP(path).then((stats) => stats.isDirectory())

export const getComponentPackageNames = () =>
Promise.all([
readdirP(coreComponents)
.then((componentDirs) =>
Promise.all(
componentDirs.map((componentDirName) =>
isDirectory(
`${coreComponents}/${componentDirName}`,
).then((isDir) => {
if (!isDir) return

return `@guardian/src-${componentDirName}`
}),
),
),
)
.then((paths) => Promise.resolve(paths.filter((path) => !!path))),
readdirP(editorialComponents)
.then((componentDirs) =>
Promise.all(
componentDirs.map((componentDirName) =>
isDirectory(
`${editorialComponents}/${componentDirName}`,
).then((isDir) => {
if (!isDir) return

return `@guardian/src-ed-${componentDirName}`
}),
),
),
)
.then((paths) => Promise.resolve(paths.filter((path) => !!path))),
]).then(([corePaths, editorialPaths]) => [...corePaths, ...editorialPaths])

export const packageNames = {
foundations: "@guardian/src-foundations",
svgs: "@guardian/src-svgs",
icons: "@guardian/src-icons",
brand: "@guardian/src-brand",
helpers: "@guardian/src-helpers",
}
25 changes: 25 additions & 0 deletions scripts/tag-beta-all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import execa from "execa"
import { version } from "../package.json"
import { packageNames, getComponentPackageNames } from "./package-names"

const tag = (packageName: string) => {
return execa("yarn", ["tag", "add", `${packageName}@${version}`, "beta"], {
stdio: "inherit",
})
}

const { foundations, svgs, icons, brand, helpers } = packageNames

const packages = getComponentPackageNames().then((ps) =>
ps.concat([foundations, svgs, icons, brand, helpers]),
)

packages.then((ps) => {
ps.forEach((packageName) => {
if (!packageName) return

tag(packageName).catch((err) =>
console.log("Error tagging packages:", err),
)
})
})

0 comments on commit aa6bd09

Please sign in to comment.