-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for native connector packaging (#30)
- Loading branch information
1 parent
e2e59f5
commit d72fe06
Showing
10 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
$ErrorActionPreference = "Stop" | ||
|
||
$minimumNodeVersion = 20 | ||
|
||
if (-not (Get-Command "node" -ErrorAction SilentlyContinue)) { | ||
Write-Host "node could not be found. Please install NodeJS v$minimumNodeVersion+." | ||
exit 1 | ||
} | ||
|
||
$nodeVersion = & node --version | ||
if ($nodeVersion -match "^v(\d+)\.") { | ||
$majorVersion = $Matches[1] | ||
if ($majorVersion -lt $minimumNodeVersion) { | ||
Write-Host "Detected Node.js version $nodeVersion on the PATH. The minimum required version is v$minimumNodeVersion." | ||
exit 1 | ||
} | ||
} | ||
|
||
Push-Location $env:HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH | ||
try { | ||
if ((Test-Path "./node_modules") -eq $false) { | ||
Write-Host "node_modules not found, please ensure you have run 'npm install'." | ||
exit 1 | ||
} | ||
} finally { | ||
Pop-Location | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
set -eu -o pipefail | ||
|
||
minimum_node_version="20" | ||
|
||
if ! command -v node &> /dev/null | ||
then | ||
echo "node could not be found on the PATH. Please install Node.js v$minimum_node_version+." | ||
exit 1 | ||
fi | ||
|
||
node_version=$(node --version) | ||
if [[ "$node_version" =~ ^v([[:digit:]]+)\. ]]; then | ||
major_version="${BASH_REMATCH[1]}" | ||
if [[ $major_version -lt $minimum_node_version ]]; then | ||
echo "Detected Node.js version $node_version on the PATH. The minimum required version is v$minimum_node_version." | ||
exit 1 | ||
fi | ||
else | ||
echo "no match" | ||
fi | ||
|
||
cd $HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH | ||
|
||
if [ ! -d "node_modules" ] | ||
then | ||
echo "node_modules directory not found, please ensure you have run 'npm install'." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// This script reads from the package.json file in the current working directory | ||
// and prints out the text in the "scripts.<name>" entry. This is used to bypass | ||
// npm, which does not handle signals correctly, and execute the command directly | ||
|
||
const fs = require("node:fs"); | ||
const process = require("node:process"); | ||
const path = require("node:path"); | ||
|
||
const cwd = process.cwd(); | ||
const packageJsonPath = path.join(cwd, "./package.json"); | ||
|
||
if (process.argv.length < 3) { | ||
console.error("Error: Pass the name of script command you want to read as the first command line arg."); | ||
console.error("Usage: node read-package-script.js <name>"); | ||
process.exit(1); | ||
} | ||
const desiredScript = process.argv[2]; | ||
|
||
try { | ||
const packageJsonText = fs.readFileSync(packageJsonPath); | ||
const packageJson = JSON.parse(packageJsonText); | ||
const script = packageJson.scripts[desiredScript]; | ||
if (script === undefined) { | ||
console.error(`Error: script ${desiredScript} not found in ${packageJsonPath}`) | ||
} | ||
console.log(script); | ||
} catch (e) { | ||
console.error(`Error reading ${packageJsonPath}: ${e}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
$ErrorActionPreference = "Stop" | ||
|
||
$scriptDir = Get-Location | ||
|
||
& ./check-reqs.ps1 | ||
|
||
Push-Location $env:HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH | ||
try { | ||
$startScript = & node "$PSScriptRoot\read-package-script.js" "start" | ||
if ($LASTEXITCODE -ne 0) { | ||
exit 1 | ||
} | ||
$env:PATH = "$($env:PATH);$($env:HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH)\node_modules\.bin" | ||
Invoke-Expression "& $startScript" | ||
} finally { | ||
Pop-Location | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
set -eu -o pipefail | ||
|
||
script_dir=$(pwd) | ||
|
||
./check-reqs.sh | ||
|
||
cd $HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH | ||
start_script=$(node "$script_dir/read-package-script.js" "start") | ||
PATH="$PATH:$(pwd)/node_modules/.bin" exec $start_script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
$ErrorActionPreference = "Stop" | ||
|
||
$scriptDir = Get-Location | ||
|
||
& ./check-reqs.ps1 | ||
|
||
Push-Location $env:HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH | ||
try { | ||
$watchScript = & node "$PSScriptRoot\read-package-script.js" "watch" | ||
if ($LASTEXITCODE -ne 0) { | ||
exit 1 | ||
} | ||
$env:PATH = "$($env:PATH);$($env:HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH)\node_modules\.bin" | ||
Invoke-Expression "& $watchScript" | ||
} finally { | ||
Pop-Location | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
set -eu -o pipefail | ||
|
||
script_dir=$(pwd) | ||
|
||
./check-reqs.sh | ||
|
||
cd $HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH | ||
watch_script=$(node "$script_dir/read-package-script.js" "watch") | ||
PATH="$PATH:$(pwd)/node_modules/.bin" exec $watch_script |