Skip to content

Commit 19dd5c3

Browse files
authored
fix: fix windows support (#211)
1 parent 94df75d commit 19dd5c3

File tree

6 files changed

+67
-15
lines changed

6 files changed

+67
-15
lines changed

.github/actions/move-artifacts/move-artifacts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function findRslintBinaries(dir = 'binaries') {
1919
// Look for files ending with -rslint in subdirectories
2020
const subEntries = fs.readdirSync(fullPath, { withFileTypes: true });
2121
for (const subEntry of subEntries) {
22-
if (subEntry.isFile() && subEntry.name.endsWith('-rslint')) {
22+
if (subEntry.isFile() && subEntry.name.includes('-rslint')) {
2323
files.push(path.join(fullPath, subEntry.name));
2424
}
2525
}

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ packages/vscode-extension/.vscode-test-out
1212
packages/vscode-extension/.vscode-test
1313
packages/rslint-test-tools/tests/typescript-eslint/fixtures
1414
packages/rslint-test-tools/tests/typescript-eslint/rules
15+
packages/rslint/pkg/
1516
pnpm-lock.yaml

npm/win32-arm64/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
"publishConfig": {
1212
"access": "public",
1313
"executableFiles": [
14-
"./rslint"
14+
"./rslint.exe"
1515
]
1616
},
1717
"files": [
18-
"rslint"
18+
"rslint.exe"
1919
],
2020
"os": [
2121
"win32"

npm/win32-x64/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
"publishConfig": {
1212
"access": "public",
1313
"executableFiles": [
14-
"./rslint"
14+
"./rslint.exe"
1515
]
1616
},
1717
"files": [
18-
"rslint"
18+
"rslint.exe"
1919
],
2020
"os": [
2121
"win32"

packages/rslint/bin/rslint.cjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ function getBinPath() {
1111
}
1212
let platformKey = `${process.platform}-${os.arch()}`;
1313

14-
return require.resolve(`@rslint/${platformKey}/rslint`);
14+
return require.resolve(
15+
`@rslint/${platformKey}/rslint${process.platform === 'win32' ? '.exe' : ''}`,
16+
);
1517
}
1618
function main() {
1719
const binPath = getBinPath();

scripts/version.mjs

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ import { $, fs, path, glob, chalk } from 'zx';
44

55
// Validate argument
66
const bumpType = process.argv[3];
7-
if (!bumpType || !['major', 'minor', 'patch'].includes(bumpType)) {
7+
const canaryMode = process.argv[4]; // Optional: 'commit' or 'timestamp' (default)
8+
9+
if (!bumpType || !['major', 'minor', 'patch', 'canary'].includes(bumpType)) {
10+
console.error(
11+
chalk.red(
12+
'❌ Usage: zx scripts/version.mjs <major|minor|patch|canary> [commit|timestamp]',
13+
),
14+
);
815
console.error(
9-
chalk.red('❌ Usage: zx scripts/version.mjs <major|minor|patch>'),
16+
chalk.gray(' For canary: timestamp (default) or commit hash'),
1017
);
1118
process.exit(1);
1219
}
@@ -16,11 +23,14 @@ console.log(chalk.blue(`🚀 Bumping all package versions: ${bumpType}`));
1623
/**
1724
* Bump semantic version
1825
* @param {string} version - Current version (e.g., "1.2.3")
19-
* @param {string} type - Bump type ("major", "minor", "patch")
20-
* @returns {string} - New version
26+
* @param {string} type - Bump type ("major", "minor", "patch", "canary")
27+
* @param {string} mode - For canary: "commit" or "timestamp" (default)
28+
* @returns {Promise<string>} - New version
2129
*/
22-
function bumpVersion(version, type) {
23-
const [major, minor, patch] = version.split('.').map(Number);
30+
async function bumpVersion(version, type, mode = 'timestamp') {
31+
// Remove existing prerelease identifiers for base version calculation
32+
const baseVersion = version.split('-')[0];
33+
const [major, minor, patch] = baseVersion.split('.').map(Number);
2434

2535
switch (type) {
2636
case 'major':
@@ -29,6 +39,26 @@ function bumpVersion(version, type) {
2939
return `${major}.${minor + 1}.0`;
3040
case 'patch':
3141
return `${major}.${minor}.${patch + 1}`;
42+
case 'canary': {
43+
// For canary, we bump patch and add canary suffix
44+
let identifier;
45+
if (mode === 'commit') {
46+
try {
47+
// Get short commit hash
48+
const commitHash = await $`git rev-parse --short HEAD`;
49+
identifier = commitHash.stdout.trim();
50+
} catch (error) {
51+
console.warn(
52+
chalk.yellow('⚠️ Failed to get commit hash, using timestamp'),
53+
);
54+
identifier = Math.floor(Date.now() / 1000);
55+
}
56+
} else {
57+
// Use timestamp (default)
58+
identifier = Math.floor(Date.now() / 1000);
59+
}
60+
return `${major}.${minor}.${patch + 1}-canary.${identifier}`;
61+
}
3262
default:
3363
throw new Error(`Invalid bump type: ${type}`);
3464
}
@@ -132,7 +162,11 @@ async function main() {
132162

133163
// Find the highest current version
134164
const highestVersion = currentVersions
135-
.map(v => v.split('.').map(Number))
165+
.map(v => {
166+
// Extract base version (remove prerelease identifiers)
167+
const baseVersion = v.split('-')[0];
168+
return baseVersion.split('.').map(Number);
169+
})
136170
.reduce((max, current) => {
137171
for (let i = 0; i < 3; i++) {
138172
if (current[i] > max[i]) return current;
@@ -152,7 +186,7 @@ async function main() {
152186
);
153187

154188
// Calculate the new version from the highest current version
155-
const newVersion = bumpVersion(highestVersion, bumpType);
189+
const newVersion = await bumpVersion(highestVersion, bumpType, canaryMode);
156190
console.log(chalk.green(`🎯 Target version: ${newVersion}`));
157191

158192
// First pass: bump all versions to the new unified version
@@ -198,7 +232,22 @@ async function main() {
198232
console.log(
199233
chalk.gray(' 3. Run: pnpm run test (to verify everything works)'),
200234
);
201-
console.log(chalk.gray(' 4. Commit changes and create release'));
235+
236+
if (bumpType === 'canary') {
237+
console.log(
238+
chalk.gray(' 4. Publish canary: pnpm run release --tag canary'),
239+
);
240+
console.log(
241+
chalk.yellow(
242+
'\n⚠️ Canary versions should be published with the "canary" tag',
243+
),
244+
);
245+
console.log(
246+
chalk.yellow(' Or use: pnpm run release:canary (automated)'),
247+
);
248+
} else {
249+
console.log(chalk.gray(' 4. Commit changes and create release'));
250+
}
202251
} catch (error) {
203252
console.error(chalk.red('❌ Error during version bump:'), error.message);
204253
process.exit(1);

0 commit comments

Comments
 (0)