Skip to content

Commit e2fb507

Browse files
committed
Publish shared v2 packages
1 parent dce7f72 commit e2fb507

7 files changed

Lines changed: 137 additions & 12 deletions

File tree

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,28 @@ jobs:
133133
echo "${TAG_NAME} already exists and ${PACKAGE_NAME}@${PACKAGE_VERSION} is already published; continuing idempotent rerun."
134134
fi
135135
136+
- name: Publish public workspace packages
137+
run: |
138+
for PACKAGE_DIR in packages/core packages/svg-renderer; do
139+
PACKAGE_NAME=$(node -p "require('./${PACKAGE_DIR}/package.json').name")
140+
PACKAGE_VERSION=$(node -p "require('./${PACKAGE_DIR}/package.json').version")
141+
142+
if node scripts/check-npm-package-exists.mjs "${PACKAGE_NAME}" "${PACKAGE_VERSION}"; then
143+
echo "Skipping ${PACKAGE_NAME}@${PACKAGE_VERSION}; already published"
144+
continue
145+
else
146+
PACKAGE_EXISTS_STATUS=$?
147+
if [ "${PACKAGE_EXISTS_STATUS}" != "1" ]; then
148+
exit "${PACKAGE_EXISTS_STATUS}"
149+
fi
150+
fi
151+
152+
npm publish "${PACKAGE_DIR}" --ignore-scripts --access public --provenance --tag "${NPM_TAG}"
153+
done
154+
env:
155+
NPM_TAG: ${{ steps.package.outputs.npm_tag }}
156+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
157+
136158
- name: Publish
137159
run: |
138160
PACKAGE_NAME="${{ steps.package.outputs.name }}"
@@ -186,6 +208,14 @@ jobs:
186208
PACKAGE_NAME: ${{ steps.package.outputs.name }}
187209
PACKAGE_VERSION: ${{ steps.package.outputs.version }}
188210

211+
- name: Verify workspace registry publish state
212+
run: |
213+
for PACKAGE_DIR in packages/core packages/svg-renderer; do
214+
PACKAGE_NAME=$(node -p "require('./${PACKAGE_DIR}/package.json').name")
215+
PACKAGE_VERSION=$(node -p "require('./${PACKAGE_DIR}/package.json').version")
216+
node scripts/check-npm-package-exists.mjs "${PACKAGE_NAME}" "${PACKAGE_VERSION}"
217+
done
218+
189219
- name: Create GitHub release
190220
env:
191221
GH_TOKEN: ${{ github.token }}

packages/core/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 indiespirit
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/core/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@chart-kit/core",
33
"version": "7.0.0-next.2",
4-
"private": true,
54
"description": "Renderer-agnostic Chart Kit v2 core scaffold.",
65
"repository": {
76
"type": "git",
@@ -21,8 +20,13 @@
2120
},
2221
"files": [
2322
"dist",
23+
"LICENSE",
2424
"README.md"
2525
],
26+
"publishConfig": {
27+
"access": "public",
28+
"registry": "https://registry.npmjs.org/"
29+
},
2630
"scripts": {
2731
"build": "tsc -p tsconfig.json",
2832
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit"

packages/svg-renderer/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 indiespirit
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/svg-renderer/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@chart-kit/svg-renderer",
33
"version": "7.0.0-next.2",
4-
"private": true,
54
"description": "SVG renderer primitives for Chart Kit v2.",
65
"repository": {
76
"type": "git",
@@ -21,8 +20,13 @@
2120
},
2221
"files": [
2322
"dist",
23+
"LICENSE",
2424
"README.md"
2525
],
26+
"publishConfig": {
27+
"access": "public",
28+
"registry": "https://registry.npmjs.org/"
29+
},
2630
"scripts": {
2731
"build": "tsc -p tsconfig.json",
2832
"typecheck": "tsc -p tsconfig.json --noEmit"

scripts/check-package-packs.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,38 @@ const npmCache = path.join(repoRoot, ".tmp", "npm-pack-cache");
88
const rootPackage = JSON.parse(
99
await readFile(path.join(repoRoot, "package.json"), "utf8")
1010
);
11+
const corePackage = JSON.parse(
12+
await readFile(path.join(repoRoot, "packages/core/package.json"), "utf8")
13+
);
14+
const svgRendererPackage = JSON.parse(
15+
await readFile(
16+
path.join(repoRoot, "packages/svg-renderer/package.json"),
17+
"utf8"
18+
)
19+
);
1120
const packageChecks = [
21+
{
22+
dir: "packages/core",
23+
name: corePackage.name,
24+
requiredFiles: [
25+
"package.json",
26+
"LICENSE",
27+
"README.md",
28+
"dist/index.js",
29+
"dist/index.d.ts"
30+
]
31+
},
32+
{
33+
dir: "packages/svg-renderer",
34+
name: svgRendererPackage.name,
35+
requiredFiles: [
36+
"package.json",
37+
"LICENSE",
38+
"README.md",
39+
"dist/index.js",
40+
"dist/index.d.ts"
41+
]
42+
},
1243
{
1344
dir: ".",
1445
name: rootPackage.name,

scripts/verify-public-surface.mjs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,6 @@ if (v2PackageJson.name !== "@chart-kit/react-native") {
138138
}
139139

140140
for (const workspacePackageJson of [corePackageJson, svgPackageJson, v2PackageJson]) {
141-
if (workspacePackageJson.private !== true) {
142-
throw new Error(`${workspacePackageJson.name} must remain private`);
143-
}
144-
145-
if (workspacePackageJson.publishConfig) {
146-
throw new Error(
147-
`${workspacePackageJson.name} must not define publishConfig`
148-
);
149-
}
150-
151141
if (
152142
!workspacePackageJson.exports?.["."] ||
153143
!workspacePackageJson.exports?.["./package.json"]
@@ -158,6 +148,30 @@ for (const workspacePackageJson of [corePackageJson, svgPackageJson, v2PackageJs
158148
}
159149
}
160150

151+
for (const publicWorkspacePackageJson of [corePackageJson, svgPackageJson]) {
152+
if (publicWorkspacePackageJson.private === true) {
153+
throw new Error(`${publicWorkspacePackageJson.name} must be publishable`);
154+
}
155+
156+
if (publicWorkspacePackageJson.license !== "MIT") {
157+
throw new Error(`${publicWorkspacePackageJson.name} must remain MIT`);
158+
}
159+
160+
if (publicWorkspacePackageJson.publishConfig?.access !== "public") {
161+
throw new Error(
162+
`${publicWorkspacePackageJson.name} must publish as public`
163+
);
164+
}
165+
}
166+
167+
if (v2PackageJson.private !== true) {
168+
throw new Error(`${v2PackageJson.name} must remain private`);
169+
}
170+
171+
if (v2PackageJson.publishConfig) {
172+
throw new Error(`${v2PackageJson.name} must not define publishConfig`);
173+
}
174+
161175
if (packageJson.main !== "./dist/index.js") {
162176
throw new Error(`Unexpected package main: ${packageJson.main}`);
163177
}

0 commit comments

Comments
 (0)