Skip to content
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
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please refer to the [Contributing Guide](https://thunderid.dev/docs/next/community/contributing/contributing-code/sdk-development/overview/) for guidelines on how to contribute to this project.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"lint": "nx run-many --target=lint --all --parallel",
"lint:fix": "nx run-many --target=lint:fix --all --parallel",
"test": "nx run-many --target=test --all --parallel",
"symlink": "node scripts/symlink.js",
"typecheck": "nx run-many --target=typecheck --all --parallel"
},
"devDependencies": {
Expand Down
103 changes: 103 additions & 0 deletions scripts/symlink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env node
/**
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this, will fix in a followup PR.

*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// Builds SDK packages, then prints link: paths and catalog version entries for use in package.json.
//
// Usage:
// node scripts/link.js # all packages
// node scripts/link.js react # only packages/react
// node scripts/link.js react browser
import { execSync } from "node:child_process";
import { existsSync, readdirSync } from "node:fs";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
const __dirname = dirname(fileURLToPath(import.meta.url));
const root = join(__dirname, "..");
const packagesDir = join(root, "packages");

const c = {
reset: "\x1b[0m",
bold: "\x1b[1m",
dim: "\x1b[2m",
green: "\x1b[32m",
cyan: "\x1b[36m",
yellow: "\x1b[33m",
gray: "\x1b[90m",
};

const args = process.argv.slice(2);
const allPackages =
args.length > 0
? args
: readdirSync(packagesDir, { withFileTypes: true })
.filter((e) => e.isDirectory())
.map((e) => e.name);

const run = (cmd, cwd) =>
execSync(cmd, { cwd, stdio: "inherit" });

// Collect valid packages first
const packageInfos = [];
for (const pkg of allPackages) {
const pkgDir = join(packagesDir, pkg);
if (!existsSync(join(pkgDir, "package.json"))) {
console.error(`${c.yellow}⚠ Skipping '${pkg}': no package.json found${c.reset}`);
continue;
}
const { name } = require(join(pkgDir, "package.json"));
packageInfos.push({ pkg, pkgDir, name });
}

// Build all in one pnpm -r command so it respects workspace dependency order
const filterArgs = packageInfos.map(({ name }) => `--filter ${name}`).join(" ");
console.error(`${c.dim}▶ building ${packageInfos.map((i) => i.name).join(", ")}...${c.reset}`);
run(`pnpm -r ${filterArgs} build`, root);

for (const { name, pkgDir } of packageInfos) {
console.error(` ${c.green}✓${c.reset} ${c.gray}${pkgDir}${c.reset}`);
}

console.error("");
console.error(`${c.bold}${c.cyan}────────────────────────────────────────────${c.reset}`);
console.error(`${c.bold}${c.cyan} file: entries — paste into package.json:${c.reset}`);
console.error(`${c.bold}${c.cyan}────────────────────────────────────────────${c.reset}`);
for (const { name, pkgDir } of packageInfos) {
process.stdout.write(` ${c.bold}"${name}"${c.reset}: ${c.green}"file:${pkgDir}"${c.reset}\n`);
}

console.error("");
console.error(`${c.bold}${c.cyan}────────────────────────────────────────────${c.reset}`);
console.error(`${c.bold}${c.cyan} overrides — paste into pnpm-workspace.yaml:${c.reset}`);
console.error(`${c.bold}${c.cyan}────────────────────────────────────────────${c.reset}`);
process.stdout.write(`${c.bold}overrides:${c.reset}\n`);
for (const { name, pkgDir } of packageInfos) {
process.stdout.write(` ${c.bold}"${name}"${c.reset}: ${c.green}"file:${pkgDir}"${c.reset}\n`);
}

console.error("");
console.error(`${c.bold}${c.cyan}────────────────────────────────────────────${c.reset}`);
console.error(`${c.bold}${c.cyan} catalog — paste into pnpm-workspace.yaml:${c.reset}`);
console.error(`${c.bold}${c.cyan}────────────────────────────────────────────${c.reset}`);
process.stdout.write(`${c.bold}catalog:${c.reset}\n`);
for (const { name, pkgDir } of packageInfos) {
process.stdout.write(` ${c.bold}"${name}"${c.reset}: ${c.green}"file:${pkgDir}"${c.reset}\n`);
}
Loading