From 6764547f13a0e5679db3ef6a9a5574631688f128 Mon Sep 17 00:00:00 2001 From: balaram Date: Tue, 10 Sep 2024 14:31:01 +0000 Subject: [PATCH] temp --- npm/gen-root.ts | 23 +++++++++-- npm/package-lock.json | 94 +------------------------------------------ t1/build-matrix.yaml | 69 +++++++++++++++++++++++++++++++ t1/index.js | 29 +++++++++++++ t1/package-lock.json | 27 +++++++++++++ t1/package.json | 17 ++++++++ 6 files changed, 163 insertions(+), 96 deletions(-) create mode 100644 t1/build-matrix.yaml create mode 100644 t1/index.js create mode 100644 t1/package-lock.json create mode 100644 t1/package.json diff --git a/npm/gen-root.ts b/npm/gen-root.ts index 7df5579617..6da35c7786 100644 --- a/npm/gen-root.ts +++ b/npm/gen-root.ts @@ -1,9 +1,9 @@ import * as fs from "fs/promises" import {resolve, dirname} from "path" -import * as yml from "yaml" import {fileURLToPath} from "url" import {parse} from "ts-command-line-args" import {PackageJson as IPackageJSON} from "type-fest" +import YML from "yaml"; const __dirname = dirname(fileURLToPath(import.meta.url)) @@ -17,6 +17,23 @@ const options = parse({ name: {alias: "n", type: String}, }) +async function get_build_matrix() { + const ciYMLPath = resolve(__dirname, "../.github/workflows/build_matrix.yml") + const ciYML = await fs.readFile(ciYMLPath, "utf8").then(YML.parse) + const steps = ciYML.jobs["setup-matrix"].steps + + for (const step of steps) { + const matrix = step?.with?.matrix + + if (matrix) { + // Parse yaml again since matrix is defined as string inside setup-matrix + return YML.parse(matrix) + } + } + + throw new Error("Cannot find matrix definition in workflow file") +} + async function genServerPackage() { const packageVersion = options.version || "0.1.0" const name = options.name || "@tailcallhq/tailcall" @@ -67,14 +84,14 @@ async function genServerPackage() { const postInstallScript = await fs.readFile(resolve(__dirname, "./post-install.js"), "utf8") const preInstallScript = await fs.readFile(resolve(__dirname, "./pre-install.js"), "utf8") const utilsScript = await fs.readFile(resolve(__dirname, "./utils.js"), "utf8") - const buildMatrix = await fs.readFile(resolve(__dirname, "../.github/build-matrix.yaml"), "utf8") + const stringified_yaml = YML.stringify(await get_build_matrix()); const postInstallScriptContent = `const version = "${packageVersion}";\n${postInstallScript}` await fs.writeFile(resolve(scriptsPath, "post-install.js"), postInstallScriptContent, "utf8") await fs.writeFile(resolve(scriptsPath, "pre-install.js"), preInstallScript, "utf8") await fs.writeFile(resolve(scriptsPath, "utils.js"), utilsScript, "utf8") - await fs.writeFile(resolve(directoryPath, "./build-matrix.yaml"), buildMatrix, "utf8") + await fs.writeFile(resolve(directoryPath, "./build-matrix.yaml"), stringified_yaml, "utf8") await fs.writeFile(resolve(directoryPath, "./package.json"), JSON.stringify(tailcallPackage, null, 2), "utf8") diff --git a/npm/package-lock.json b/npm/package-lock.json index 2fca465b6d..f847a49984 100644 --- a/npm/package-lock.json +++ b/npm/package-lock.json @@ -9,8 +9,7 @@ "dependencies": { "ts-command-line-args": "^2.5.1", "type-fest": "^4.7.1", - "yaml": "^2.3.3", - "yml": "^1.0.0" + "yaml": "^2.3.3" }, "devDependencies": { "tsx": "^4.1.0" @@ -438,14 +437,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, "node_modules/array-back": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", @@ -641,18 +632,6 @@ "node": ">=0.8.0" } }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/find-replace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", @@ -678,14 +657,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/get-tsconfig": { "version": "4.7.5", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.5.tgz", @@ -707,59 +678,11 @@ "node": ">=8" } }, - "node_modules/hasown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", - "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/is": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/is/-/is-3.3.0.tgz", - "integrity": "sha512-nW24QBoPcFGGHJGUwnfpI7Yc5CdqWNdsyHQszVE/z2pKHXzh7FZ5GWhJqSyaQ9wMkQnsTx+kAI8bHlCX4tKdbg==", - "engines": { - "node": "*" - } - }, - "node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, "node_modules/lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==" }, - "node_modules/node.extend": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/node.extend/-/node.extend-2.0.3.tgz", - "integrity": "sha512-xwADg/okH48PvBmRZyoX8i8GJaKuJ1CqlqotlZOhUio8egD1P5trJupHKBzcPjSF9ifK2gPcEICRBnkfPqQXZw==", - "dependencies": { - "hasown": "^2.0.0", - "is": "^3.3.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/reduce-flatten": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/reduce-flatten/-/reduce-flatten-2.0.0.tgz", @@ -777,11 +700,6 @@ "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" - }, "node_modules/string-format": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/string-format/-/string-format-2.0.0.tgz", @@ -913,16 +831,6 @@ "engines": { "node": ">= 14" } - }, - "node_modules/yml": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/yml/-/yml-1.0.0.tgz", - "integrity": "sha512-x9KKVpZtKunwoi6J7fCtiAJkV+M4F5woMD8RQJ7wv3DkIBrIx70XOryhnSFbwXxpLsH/s1reCxSZ1CPHUr0PWg==", - "dependencies": { - "js-yaml": "^3.9.0", - "lodash": "^4.17.4", - "node.extend": "^2.0.0" - } } } } diff --git a/t1/build-matrix.yaml b/t1/build-matrix.yaml new file mode 100644 index 0000000000..59eb1eec65 --- /dev/null +++ b/t1/build-matrix.yaml @@ -0,0 +1,69 @@ +build: + - linux-x64-gnu + - linux-x64-musl + - linux-arm64-gnu + - linux-arm64-musl + - linux-ia32-gnu + - darwin-arm64 + - darwin-x64 + - win32-x64-msvc + - win32-arm64-msvc + - win32-ia32-msvc +include: + - build: linux-x64-gnu + os: ubuntu-latest + rust: stable + target: x86_64-unknown-linux-gnu + libc: glibc + - build: linux-x64-musl + os: ubuntu-latest + rust: stable + target: x86_64-unknown-linux-musl + libc: musl + cross: true + - build: linux-arm64-gnu + os: ubuntu-latest + rust: stable + target: aarch64-unknown-linux-gnu + libc: glibc + cross: true + - build: linux-arm64-musl + os: ubuntu-latest + rust: stable + target: aarch64-unknown-linux-musl + libc: musl + cross: true + - build: linux-ia32-gnu + os: ubuntu-latest + rust: stable + target: i686-unknown-linux-gnu + libc: glibc + cross: true + - build: darwin-arm64 + os: macos-latest + rust: stable + target: aarch64-apple-darwin + - build: darwin-x64 + os: macos-latest + rust: stable + target: x86_64-apple-darwin + - build: win32-x64-msvc + os: windows-latest + rust: stable + target: x86_64-pc-windows-msvc + libc: msvc + ext: .exe + - build: win32-arm64-msvc + os: windows-latest + rust: stable + target: aarch64-pc-windows-msvc + features: --no-default-features --features cli + libc: msvc + ext: .exe + test: false + - build: win32-ia32-msvc + os: windows-latest + rust: stable + target: i686-pc-windows-msvc + libc: msvc + ext: .exe diff --git a/t1/index.js b/t1/index.js new file mode 100644 index 0000000000..de5a2d0d73 --- /dev/null +++ b/t1/index.js @@ -0,0 +1,29 @@ +import YML from 'yaml'; +import * as fs from "fs/promises"; +import {resolve, dirname} from "path"; +import {fileURLToPath} from "url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const stringified_yaml = YML.stringify(await get_build_matrix()); //YML.parse(workflow_file).jobs["setup-matrix"].steps.); +console.log(stringified_yaml); + +await fs.writeFile(resolve(__dirname, "./build-matrix.yaml"), stringified_yaml, "utf8") + + + +async function get_build_matrix() { + const ciYMLPath = resolve(__dirname, "../.github/workflows/build_matrix.yml") + const ciYML = await fs.readFile(ciYMLPath, "utf8").then(YML.parse) + const steps = ciYML.jobs["setup-matrix"].steps + + for (const step of steps) { + const matrix = step?.with?.matrix + + if (matrix) { + // Parse yaml again since matrix is defined as string inside setup-matrix + return YML.parse(matrix) + } + } + + throw new Error("Cannot find matrix definition in workflow file") +} \ No newline at end of file diff --git a/t1/package-lock.json b/t1/package-lock.json new file mode 100644 index 0000000000..d05a6fcd98 --- /dev/null +++ b/t1/package-lock.json @@ -0,0 +1,27 @@ +{ + "name": "t1", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "t1", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "yaml": "^2.5.1" + } + }, + "node_modules/yaml": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz", + "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + } + } +} diff --git a/t1/package.json b/t1/package.json new file mode 100644 index 0000000000..aaa357e44c --- /dev/null +++ b/t1/package.json @@ -0,0 +1,17 @@ +{ + "name": "t1", + "type": "module", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "dev": "node index.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "yaml": "^2.5.1" + } +}