Skip to content

Commit 0e91c93

Browse files
committed
feat: initial import from poc
1 parent 72d26e7 commit 0e91c93

File tree

7 files changed

+220
-0
lines changed

7 files changed

+220
-0
lines changed

.github/workflows/next-build.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#
2+
# Copyright (C) 2025 Red Hat, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# SPDX-License-Identifier: Apache-2.0
17+
18+
name: next build
19+
20+
on:
21+
workflow_dispatch:
22+
push:
23+
branches:
24+
- main
25+
26+
env:
27+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
28+
29+
jobs:
30+
31+
publish:
32+
runs-on: ubuntu-24.04
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- uses: pnpm/action-setup@v4
37+
name: Install pnpm
38+
with:
39+
run_install: false
40+
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: 22
44+
cache: 'pnpm'
45+
46+
- name: Execute pnpm
47+
run: pnpm install
48+
49+
- name: Run Build
50+
run: |
51+
pnpm build
52+
53+
- name: Set-up npmjs auth token
54+
run: printf "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}\n" >> ~/.npmrc
55+
56+
- name: Download macadam binaries
57+
run: |
58+
MACADAM_VERSION=v0.0.2
59+
mkdir binaries
60+
curl -L https://github.com/crc-org/macadam/releases/download/${MACADAM_VERSION}/macadam-windows-amd64.exe -o binaries/macadam-windows-amd64.exe
61+
curl -L https://github.com/crc-org/macadam/releases/download/${MACADAM_VERSION}/macadam-darwin-amd64 -o binaries/macadam-darwin-amd64
62+
curl -L https://github.com/crc-org/macadam/releases/download/${MACADAM_VERSION}/macadam-darwin-arm64 -o binaries/macadam-darwin-arm64
63+
64+
- name: Publish to npmjs
65+
run: |
66+
PACKAGE_VERSION=$(jq -r '.version' package.json)
67+
STRIPPED_VERSION=${PACKAGE_VERSION%-next}
68+
SHORT_SHA1=$(git rev-parse --short HEAD)
69+
TAG_PATTERN=${STRIPPED_VERSION}-$(date +'%Y%m%d%H%M')-${SHORT_SHA1}
70+
echo "Using version ${TAG_PATTERN}"
71+
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${TAG_PATTERN}\",#g" package.json
72+
pnpm publish --tag next --no-git-checks --access public

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
.DS_Store
3+
dist
4+
.eslintcache
5+
**/coverage
6+
.idea
7+
output
8+
.npmrc

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "macadam.js",
3+
"version": "0.0.1",
4+
"description": "An NPM library to work with macadam from Node projects",
5+
"main": "./dist/index.js",
6+
"scripts": {
7+
"build": "npx tsc --build",
8+
"clean": "npx tsc --build --clean"
9+
},
10+
"license": "Apache-2.0",
11+
"devDependencies": {
12+
"@types/node": "^22.14.0",
13+
"typescript": "^5.8.3"
14+
},
15+
"files": [
16+
"dist",
17+
"binaries",
18+
"!dist/tsconfig.tsbuildinfo"
19+
],
20+
"packageManager": "[email protected]+sha512.47870716bea1572b53df34ad8647b42962bc790ce2bf4562ba0f643237d7302a3d6a8ecef9e4bdfc01d23af1969aa90485d4cebb0b9638fa5ef1daef656f6c1b"
21+
}

pnpm-lock.yaml

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/consts.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**********************************************************************
2+
* Copyright (C) 2025 Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
***********************************************************************/
18+
19+
export const PACKAGE_NAME = 'macadam.js';

src/index.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**********************************************************************
2+
* Copyright (C) 2025 Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
***********************************************************************/
18+
import * as path from 'node:path';
19+
import * as os from 'node:os';
20+
import * as fs from 'node:fs';
21+
import { PACKAGE_NAME } from './consts';
22+
23+
export async function getMacadamPath(): Promise<string> {
24+
let bin = '';
25+
if (os.platform() === 'win32') {
26+
bin = 'macadam-windows-amd64.exe';
27+
} else if (os.platform() === 'darwin') {
28+
if (os.arch() === 'arm64') {
29+
bin = 'macadam-darwin-arm64';
30+
} else if (os.arch() == 'x64') {
31+
bin = 'macadam-darwin-amd64';
32+
}
33+
}
34+
if (!bin) {
35+
throw new Error(`binary not found for platform ${os.platform()} and architecture ${os.arch()}`);
36+
}
37+
const packagePath = path.dirname(require.resolve(`${PACKAGE_NAME}/package.json`));
38+
39+
const filepath = path.resolve(packagePath, 'binaries', bin);
40+
await fs.promises.chmod(filepath, '755');
41+
return filepath;
42+
}

tsconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"module": "esnext",
5+
"moduleResolution": "node",
6+
"declaration": true,
7+
"outDir": "./dist",
8+
"esModuleInterop": true,
9+
"forceConsistentCasingInFileNames": true,
10+
"types": [
11+
"node",
12+
],
13+
"strict": true,
14+
"skipLibCheck": true
15+
},
16+
"include": [
17+
"src/*.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)