Skip to content

Commit ff2e318

Browse files
committed
ditching consts for direct pkg axx
1 parent 8413bdd commit ff2e318

File tree

1 file changed

+35
-36
lines changed

1 file changed

+35
-36
lines changed

.github/workflows/publish_x402_matrix.yml

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -52,59 +52,58 @@ jobs:
5252
run: |
5353
SELECTED="${{ matrix.package }}"
5454
55-
# Extract base package information
56-
BASE_NAME=$(node -p "require('./package.json').name")
57-
BASE_VERSION=$(node -p "require('./package.json').version")
58-
59-
# Use JSON.stringify to ensure proper escaping
60-
BASE_AUTHOR_JSON=$(node -p "JSON.stringify(require('./package.json').author || '')")
61-
BASE_LICENSE_JSON=$(node -p "JSON.stringify(require('./package.json').license || '')")
62-
BASE_REPOSITORY_JSON=$(node -p "JSON.stringify(require('./package.json').repository || {})")
63-
64-
# Check for component-specific version file
65-
if [ -f "src/$SELECTED/version" ]; then
66-
COMPONENT_VERSION=$(cat "src/$SELECTED/version")
67-
echo "Using component-specific version: $COMPONENT_VERSION for $SELECTED"
68-
else
69-
COMPONENT_VERSION="$BASE_VERSION"
70-
echo "Using base version: $COMPONENT_VERSION for $SELECTED"
71-
fi
72-
73-
# Create package.json using node to ensure valid JSON
7455
node -e "
7556
const fs = require('fs');
7657
const path = require('path');
7758
78-
const packageJson = {
79-
name: '${BASE_NAME}-${SELECTED}',
80-
version: '${COMPONENT_VERSION}',
81-
description: '${SELECTED} integration for x402',
59+
const COMPONENT = '${{ matrix.package }}';
60+
const sourceDir = path.join('src', COMPONENT);
61+
const targetDir = path.join('dist', COMPONENT);
62+
63+
// Load base package.json
64+
const basePackage = require('./package.json');
65+
66+
// Determine version (component-specific or base)
67+
let version = basePackage.version;
68+
const versionFile = path.join(sourceDir, 'version');
69+
70+
if (fs.existsSync(versionFile)) {
71+
version = fs.readFileSync(versionFile, 'utf8').trim();
72+
console.log(`Using component-specific version: ${version} for ${COMPONENT}`);
73+
} else {
74+
console.log(`Using base version: ${version} for ${COMPONENT}`);
75+
}
76+
77+
// Create component package.json
78+
const componentPackage = {
79+
name: `${basePackage.name}-${COMPONENT}`,
80+
version,
81+
description: `${COMPONENT} integration for x402`,
8282
main: 'index.js',
8383
types: 'index.d.ts',
84-
author: ${BASE_AUTHOR_JSON},
85-
license: ${BASE_LICENSE_JSON},
86-
repository: JSON.parse(${BASE_REPOSITORY_JSON}),
84+
author: basePackage.author || '',
85+
license: basePackage.license || '',
86+
repository: basePackage.repository || '',
8787
dependencies: {
88-
'${BASE_NAME}': '^${BASE_VERSION}'
88+
[basePackage.name]: `^${basePackage.version}`
8989
},
9090
peerDependencies: {
91-
'${SELECTED}': '*'
91+
[COMPONENT]: '*'
9292
}
9393
};
9494
95-
// Ensure directory exists
96-
const dir = path.join('dist', '${SELECTED}');
97-
if (!fs.existsSync(dir)){
98-
fs.mkdirSync(dir, { recursive: true });
95+
// Ensure target directory exists
96+
if (!fs.existsSync(targetDir)) {
97+
fs.mkdirSync(targetDir, { recursive: true });
9998
}
10099
101-
// Write the file
100+
// Write the package.json file
102101
fs.writeFileSync(
103-
path.join(dir, 'package.json'),
104-
JSON.stringify(packageJson, null, 2)
102+
path.join(targetDir, 'package.json'),
103+
JSON.stringify(componentPackage, null, 2)
105104
);
106105
107-
console.log('Generated package.json for ${SELECTED}');
106+
console.log(`Generated package.json for ${COMPONENT}`);
108107
"
109108
110109
- name: Publish ${{ matrix.package }} package (dry-run for non-main branches)

0 commit comments

Comments
 (0)