@forwardslashns/taskit-validation-messages 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/publish.js +53 -0
- package/publish.ps1 +0 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forwardslashns/taskit-validation-messages",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "rimraf ./dist && tsc",
|
|
32
32
|
"format:fix": "prettier --write --ignore-path .gitignore .",
|
|
33
|
-
"publish:token": "
|
|
33
|
+
"publish:token": "node ./publish.js"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/publish.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const loadEnvironmentVariables = () => {
|
|
6
|
+
const envPath = path.resolve(__dirname, '.env');
|
|
7
|
+
if (fs.existsSync(envPath)) {
|
|
8
|
+
const envContent = fs.readFileSync(envPath, 'utf8');
|
|
9
|
+
envContent.split('\n').forEach((line) => {
|
|
10
|
+
const trimmed = line.trim();
|
|
11
|
+
if (trimmed && !trimmed.startsWith('#') && trimmed.includes('=')) {
|
|
12
|
+
const [key, ...values] = trimmed.split('=');
|
|
13
|
+
const val = values.join('=').trim().replace(/^["']|["']$/g, '');
|
|
14
|
+
if (key && val) {
|
|
15
|
+
process.env[key.trim()] = val;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
console.log('Environment variables loaded.');
|
|
20
|
+
} else {
|
|
21
|
+
console.log('No .env file found. Using system environment variables.');
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const validateToken = () => {
|
|
26
|
+
if (!process.env.NPM_TOKEN) {
|
|
27
|
+
console.error('\x1b[31mError: NPM_TOKEN is missing.\x1b[0m');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
console.log('NPM_TOKEN verified.');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const executePublish = () => {
|
|
34
|
+
try {
|
|
35
|
+
console.log('Starting publish process (skipping git checks)...');
|
|
36
|
+
execSync('pnpm publish --no-git-checks --ignore-scripts', {
|
|
37
|
+
stdio: 'inherit',
|
|
38
|
+
env: process.env,
|
|
39
|
+
cwd: __dirname,
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('\x1b[31mPublish process encountered an error.\x1b[0m');
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const main = () => {
|
|
48
|
+
loadEnvironmentVariables();
|
|
49
|
+
validateToken();
|
|
50
|
+
executePublish();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
main();
|
package/publish.ps1
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# Load environment variables from .env file
|
|
2
|
-
if (Test-Path .env) {
|
|
3
|
-
Get-Content .env | ForEach-Object {
|
|
4
|
-
if ($_ -match '^([^=]+)=(.*)$') {
|
|
5
|
-
$key = $matches[1].Trim()
|
|
6
|
-
$value = $matches[2].Trim()
|
|
7
|
-
Set-Item -Path "env:$key" -Value $value
|
|
8
|
-
Write-Host "Loaded $key from .env"
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
} else {
|
|
12
|
-
Write-Host "Error: .env file not found. Copy .env.example to .env and add your NPM_TOKEN" -ForegroundColor Red
|
|
13
|
-
exit 1
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
# Verify NPM_TOKEN is set
|
|
17
|
-
if (-not $env:NPM_TOKEN) {
|
|
18
|
-
Write-Host "Error: NPM_TOKEN not set in .env file" -ForegroundColor Red
|
|
19
|
-
exit 1
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
Write-Host "NPM_TOKEN loaded (length: $($env:NPM_TOKEN.Length) chars)" -ForegroundColor Cyan
|
|
23
|
-
|
|
24
|
-
# Backup original .npmrc
|
|
25
|
-
Copy-Item .npmrc .npmrc.backup -Force
|
|
26
|
-
|
|
27
|
-
# Replace ${NPM_TOKEN} with actual token in .npmrc
|
|
28
|
-
$npmrcContent = Get-Content .npmrc -Raw
|
|
29
|
-
$npmrcContent = $npmrcContent -replace '\$\{NPM_TOKEN\}', $env:NPM_TOKEN
|
|
30
|
-
Set-Content .npmrc $npmrcContent
|
|
31
|
-
|
|
32
|
-
Write-Host "Publishing package from current branch..." -ForegroundColor Green
|
|
33
|
-
pnpm publish --no-git-checks
|
|
34
|
-
|
|
35
|
-
# Restore original .npmrc
|
|
36
|
-
Move-Item .npmrc.backup .npmrc -Force
|
|
37
|
-
Write-Host "Restored .npmrc" -ForegroundColor Cyan
|