diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index 1790b3b..a353f92 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -44,12 +44,6 @@ jobs: TOOLCHAIN: stable, TARGET: i686-pc-windows-msvc, } - - { - NAME: win32-arm64-msvc, - OS: windows-2022, - TOOLCHAIN: stable, - TARGET: aarch64-pc-windows-msvc, - } - { NAME: darwin-x64, OS: macos-11, @@ -108,9 +102,9 @@ jobs: # set the package name # note: use 'windows' as OS name instead of 'win32' if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then - export node_pkg="${bin}-windows-${node_arch}" + export node_pkg="${bin}-cli-windows-${node_arch}" else - export node_pkg="${bin}-${node_os}-${node_arch}" + export node_pkg="${bin}-cli-${node_os}-${node_arch}" fi echo "node_pkg=${node_pkg}" >> $GITHUB_ENV # create the package directory @@ -152,5 +146,21 @@ jobs: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }} npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + publish-wrapper-npm-package: + name: Publish wrapper NPM packages + runs-on: ubuntu-20.04 + needs: publish-npm-binaries + steps: + - name: Publish the NPM package + shell: bash + run: | + cd cli/npm-package + npm run build + cd lib + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc + npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }} + npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index ca5423d..545e4f3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ tests/examples/.yarn cli/npm-package/lib cli/npm-package/.npmrc cli/npm-package/.yarnrc +cli/npm-package/package-lock.json .npmrc .yarnrc diff --git a/cli/npm-package/bolt.ts b/cli/npm-package/bolt.ts index 942a47d..66cfb2a 100755 --- a/cli/npm-package/bolt.ts +++ b/cli/npm-package/bolt.ts @@ -23,8 +23,7 @@ function getExePath(): string { os = "windows"; extension = ".exe"; } - - const binaryName = `@magicblock-labs/bolt-${os}-${arch()}/bin/bolt${extension}`; + const binaryName = `@magicblock-labs/bolt-cli-${os}-${arch()}/bin/bolt${extension}`; try { return require.resolve(binaryName); } catch (e) { @@ -68,8 +67,6 @@ function tryPackageBolt(): boolean { } function trySystemBolt(): void { - console.error("Trying globally installed bolt."); - const absolutePath = process.env.PATH?.split(path.delimiter) .filter((dir) => dir !== path.dirname(process.argv[1])) .find((dir) => { @@ -83,7 +80,7 @@ function trySystemBolt(): void { if (!absolutePath) { console.error( - `Could not find globally installed bolt, install with cargo.` + `Could not find globally installed bolt, please install with cargo.` ); process.exit(1); } @@ -104,5 +101,4 @@ function trySystemBolt(): void { runBolt(absoluteBinaryPath); } - tryPackageBolt() || trySystemBolt(); diff --git a/cli/npm-package/package.json b/cli/npm-package/package.json index 55169b0..0ba6964 100644 --- a/cli/npm-package/package.json +++ b/cli/npm-package/package.json @@ -15,7 +15,6 @@ "bolt": "lib/bolt.js" }, "scripts": { - "postinstall": "node scripts/setupNpmRegistry.js", "typecheck": "tsc --noEmit", "lint": "eslint .", "lint:fix": "eslint . --fix", @@ -30,12 +29,13 @@ "typescript": "^4.9.4" }, "optionalDependencies": { - "@magicblock-labs/bolt-linux-x64": "0.0.1", - "@magicblock-labs/bolt-linux-arm64": "0.0.1", - "@magicblock-labs/bolt-darwin-x64": "0.0.1", - "@magicblock-labs/bolt-darwin-arm64": "0.0.1", - "@magicblock-labs/bolt-windows-x64": "0.0.1", - "@magicblock-labs/bolt-windows-arm64": "0.0.1" + "@magicblock-labs/bolt-cli-darwin-x64": "0.0.1", + "@magicblock-labs/bolt-cli-darwin-arm64": "0.0.1", + "@magicblock-labs/bolt-cli-linux-x86": "0.0.1", + "@magicblock-labs/bolt-cli-linux-x64": "0.0.1", + "@magicblock-labs/bolt-cli-linux-arm64": "0.0.1", + "@magicblock-labs/bolt-cli-windows-x86": "0.0.1", + "@magicblock-labs/bolt-cli-windows-x64": "0.0.1" }, "publishConfig": { "access": "public" diff --git a/cli/npm-package/scripts/setupNpmRegistry.js b/cli/npm-package/scripts/setupNpmRegistry.js deleted file mode 100644 index a2723e0..0000000 --- a/cli/npm-package/scripts/setupNpmRegistry.js +++ /dev/null @@ -1,31 +0,0 @@ -const fs = require("fs"); -const path = require("path"); - -// Configuration for both npm and Yarn -const npmrcPath = path.join(process.cwd(), ".npmrc"); -const yarnrcPath = path.join(process.cwd(), ".yarnrc"); -const npmConfigLine = - "@magicblock-labs:registry=https://npm.pkg.github.com/magicblock-labs\n"; -const yarnConfigLine = - '"@magicblock-labs:registry" "https://npm.pkg.github.com/magicblock-labs"\n'; - -// Function to update or create a configuration file -function updateOrCreateConfig(filePath, configLine) { - try { - if (fs.existsSync(filePath)) { - const content = fs.readFileSync(filePath, { encoding: "utf8" }); - if (!content.includes(configLine)) { - fs.appendFileSync(filePath, configLine); - } - } else { - fs.writeFileSync(filePath, configLine); - } - console.log(`${path.basename(filePath)} configured successfully.`); - } catch (error) { - console.error(`Error configuring ${path.basename(filePath)}:`, error); - } -} - -// Update or create both .npmrc and .yarnrc -updateOrCreateConfig(npmrcPath, npmConfigLine); -updateOrCreateConfig(yarnrcPath, yarnConfigLine);