Skip to content

Commit ee5e74f

Browse files
committed
build: updating npm publish script, creating zips for github releases
1 parent 0ca06e3 commit ee5e74f

4 files changed

Lines changed: 34 additions & 15 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run_install: false
4141

4242
- name: Initialize Nx Cloud
43-
run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js"
43+
run: pnpm nx-cloud start-ci-run --distribute-on="5 linux-medium-js"
4444

4545
- name: Get pnpm store directory
4646
id: pnpm-cache
@@ -58,20 +58,20 @@ jobs:
5858
run: pnpm install
5959

6060
- name: Build All Packages
61-
run: npx nx run-many -t build:ci
61+
run: pnpm nx run-many -t build:ci
6262
env:
6363
CI: true
6464

6565
# 📦 ZIP artifacts (solo stable)
6666
- name: Generate zip artifacts
6767
if: env.IS_STABLE == 'true'
68-
run: node scripts/package-zips.js
68+
run: pnpm run release:zip-artifacts
6969

7070
# 🚀 Publish npm
7171
- name: Publish to NPM (OIDC Auth)
7272
run: |
7373
TAG="${GITHUB_REF#refs/tags/}"
74-
BASE_CMD="npx lerna publish from-package --ignore-scripts"
74+
BASE_CMD="pnpm lerna publish from-package --ignore-scripts"
7575
7676
echo "Publishing tag: $TAG via OIDC"
7777
@@ -103,7 +103,7 @@ jobs:
103103
if: env.IS_STABLE == 'true'
104104
run: |
105105
echo "${{ steps.release.outputs.body }}" > RAW_RELEASE.md
106-
node scripts/prettify-changelog.js
106+
pnpm run release:prettify-changelog
107107
108108
# 🔁 Update release con changelog finale
109109
- name: Update Release Notes
@@ -114,5 +114,5 @@ jobs:
114114
body_path: RELEASE_NOTES.md
115115

116116
- name: Stop Nx Cloud Session
117-
run: npx nx fix-ci
117+
run: pnpm nx fix-ci
118118
if: always()

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"name": "@tsparticles/workspace",
44
"description": "tsParticles monorepository",
55
"version": "0.0.0",
6+
"type": "module",
67
"scripts": {
78
"slimbuild": "pnpm run prettify:readme && nx run-many -t build --parallel=50%",
89
"slimbuild:ci": "pnpm run prettify:ci:readme && nx run-many -t build:ci",
@@ -23,6 +24,8 @@
2324
"publish:v3": "lerna publish from-package --dist-tag v3",
2425
"publish:v2": "lerna publish from-package --dist-tag v2",
2526
"publish:v1": "lerna publish from-package --dist-tag v1",
27+
"release:zip-artifacts": "node scripts/package-zips.js",
28+
"release:prettify-changelog": "node scripts/prettify-changelog.js",
2629
"deploy:docs:json": "node deploy.docs-json.js",
2730
"prepare": "husky"
2831
},

scripts/package-zips.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { execSync } from "node:child_process";
22
import { readdirSync, existsSync, readFileSync, mkdirSync, rmSync } from "node:fs";
3-
import { join } from "node:path";
3+
import { join, relative } from "node:path";
44

55
const ROOT = process.cwd();
66
const OUTPUT_DIR = join(ROOT, "release-artifacts");
7+
const SKIPPED_PATH_PREFIXES = ["demo", "utils/tests"];
8+
const SKIPPED_DIR_NAMES = new Set([".git", "node_modules", "dist", "release-artifacts"]);
79

810
// Clean output directory
911
rmSync(OUTPUT_DIR, { recursive: true, force: true });
@@ -17,18 +19,30 @@ function findPackages(dir) {
1719
const packages = [];
1820

1921
for (const entry of entries) {
22+
if (!entry.isDirectory()) {
23+
continue;
24+
}
25+
26+
if (SKIPPED_DIR_NAMES.has(entry.name)) {
27+
continue;
28+
}
29+
2030
const fullPath = join(dir, entry.name);
31+
const relativePath = relative(ROOT, fullPath).replace(/\\/g, "/");
2132

22-
if (entry.isDirectory()) {
23-
const packageJsonPath = join(fullPath, "package.json");
33+
// Ignore excluded trees entirely (demo/** and utils/tests/**).
34+
if (SKIPPED_PATH_PREFIXES.some((prefix) => relativePath === prefix || relativePath.startsWith(`${prefix}/`))) {
35+
continue;
36+
}
2437

25-
if (existsSync(packageJsonPath)) {
26-
packages.push(fullPath);
27-
}
38+
const packageJsonPath = join(fullPath, "package.json");
2839

29-
// Continue searching nested folders
30-
packages.push(...findPackages(fullPath));
40+
if (existsSync(packageJsonPath)) {
41+
packages.push(fullPath);
3142
}
43+
44+
// Continue searching nested folders
45+
packages.push(...findPackages(fullPath));
3246
}
3347

3448
return packages;
@@ -57,10 +71,12 @@ for (const pkgPath of allPackages) {
5771

5872
const pkgJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
5973

60-
const name = pkgJson.name
74+
const normalizedName = pkgJson.name
6175
.replace(/^@[^/]+\//, "") // remove scope if present
6276
.replace(/\//g, "-"); // safety
6377

78+
const name = normalizedName.startsWith("tsparticles") ? normalizedName : `tsparticles-${normalizedName}`;
79+
6480
const version = pkgJson.version;
6581

6682
const zipName = `${name}-${version}.zip`;

0 commit comments

Comments
 (0)