Skip to content

Commit

Permalink
📝 Use npm
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielePicco committed Feb 23, 2024
1 parent 8e9cae4 commit 60b54fa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 52 deletions.
26 changes: 18 additions & 8 deletions .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

8 changes: 2 additions & 6 deletions cli/npm-package/bolt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) => {
Expand All @@ -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);
}
Expand All @@ -104,5 +101,4 @@ function trySystemBolt(): void {

runBolt(absoluteBinaryPath);
}

tryPackageBolt() || trySystemBolt();
14 changes: 7 additions & 7 deletions cli/npm-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"bolt": "lib/bolt.js"
},
"scripts": {
"postinstall": "node scripts/setupNpmRegistry.js",
"typecheck": "tsc --noEmit",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
Expand All @@ -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"
Expand Down
31 changes: 0 additions & 31 deletions cli/npm-package/scripts/setupNpmRegistry.js

This file was deleted.

0 comments on commit 60b54fa

Please sign in to comment.