@nosto/nosto-cli 1.0.1 → 1.0.2

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 CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@nosto/nosto-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "main": "./src/index.ts",
5
5
  "bin": {
6
- "nosto": "./src/bootstrap.sh"
6
+ "nosto": "./src/bootstrap.mjs"
7
7
  },
8
8
  "author": "Nosto",
9
9
  "type": "module",
@@ -33,9 +33,10 @@
33
33
  "commander": "^14.0.1",
34
34
  "esbuild": "^0.25.10",
35
35
  "ignore": "^7.0.5",
36
- "open": "^10.2.0",
37
36
  "ky": "^1.11.0",
37
+ "open": "^10.2.0",
38
38
  "preact": "^10.27.2",
39
+ "tsx": "^4.20.6",
39
40
  "zod": "^4.1.11"
40
41
  },
41
42
  "devDependencies": {
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process"
3
+ import { dirname, resolve } from "node:path"
4
+ import { fileURLToPath } from "node:url"
5
+
6
+ const directoryName = dirname(fileURLToPath(import.meta.url))
7
+
8
+ const loaderUrl = import.meta.resolve("tsx")
9
+ const loaderPath = fileURLToPath(loaderUrl)
10
+
11
+ const entry = resolve(directoryName, "index.ts")
12
+ const child = spawn(process.execPath, ["--import", loaderPath, entry, ...process.argv.slice(2)], { stdio: "inherit" })
13
+
14
+ child.on("exit", (code, signal) => {
15
+ if (signal) process.kill(process.pid, signal)
16
+ else process.exit(code ?? 0)
17
+ })
package/src/commander.ts CHANGED
@@ -42,7 +42,7 @@ export async function runCLI(argv: string[]) {
42
42
  .description("Prints setup information and creates a configuration file")
43
43
  .option("-m, --merchant <merchant>", "merchant to create config for")
44
44
  .action(async (projectPath = ".", options) => {
45
- await loadConfig({ options, allowIncomplete: true, projectPath: "." })
45
+ await loadConfig({ options, allowIncomplete: true, projectPath })
46
46
  await withErrorHandler(() => printSetupHelp(projectPath, options))
47
47
  })
48
48
 
@@ -50,7 +50,7 @@ export async function runCLI(argv: string[]) {
50
50
  .command("status [projectPath]")
51
51
  .description("Print the configuration status")
52
52
  .action(async (projectPath = ".", options) => {
53
- await loadConfig({ options, allowIncomplete: true, projectPath: "." })
53
+ await loadConfig({ options, allowIncomplete: true, projectPath })
54
54
  await withErrorHandler(() => printStatus(projectPath))
55
55
  })
56
56
 
@@ -1,14 +1,17 @@
1
1
  import crypto from "crypto"
2
2
  import fs from "fs"
3
+ import path from "path"
3
4
 
4
5
  import { getCachedConfig } from "#config/config.ts"
5
6
 
6
7
  import { getIgnoreInstance } from "./isIgnored.ts"
7
8
 
8
9
  export function calculateTreeHash() {
10
+ const { projectPath } = getCachedConfig()
9
11
  const hash = crypto.createHash("sha256")
10
12
  for (const filePath of listAllFilesForHashing()) {
11
- const fileContent = fs.readFileSync(filePath, "utf-8")
13
+ const fullFilePath = path.join(projectPath, filePath)
14
+ const fileContent = fs.readFileSync(fullFilePath, "utf-8")
12
15
  hash.update(fileContent)
13
16
  }
14
17
  return hash.digest("hex")
package/src/bootstrap.sh DELETED
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # A more robust way to get the script directory that works with symlinks
4
- get_script_dir()
5
- {
6
- local SOURCE_PATH="${BASH_SOURCE[0]}"
7
- local SYMLINK_DIR
8
- local SCRIPT_DIR
9
- # Resolve symlinks recursively
10
- while [ -L "$SOURCE_PATH" ]; do
11
- # Get symlink directory
12
- SYMLINK_DIR="$( cd -P "$( dirname "$SOURCE_PATH" )" >/dev/null 2>&1 && pwd )"
13
- # Resolve symlink target (relative or absolute)
14
- SOURCE_PATH="$(readlink "$SOURCE_PATH")"
15
- # Check if candidate path is relative or absolute
16
- if [[ $SOURCE_PATH != /* ]]; then
17
- # Candidate path is relative, resolve to full path
18
- SOURCE_PATH=$SYMLINK_DIR/$SOURCE_PATH
19
- fi
20
- done
21
- # Get final script directory path from fully resolved source path
22
- SCRIPT_DIR="$(cd -P "$( dirname "$SOURCE_PATH" )" >/dev/null 2>&1 && pwd)"
23
- echo "$SCRIPT_DIR"
24
- }
25
-
26
- exec node --experimental-strip-types --disable-warning=ExperimentalWarning "$(get_script_dir)/index.ts" "$@"