@nosto/nosto-cli 1.0.1 → 1.0.3
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/.github/workflows/ci.yml +0 -2
- package/README.md +15 -11
- package/package.json +4 -3
- package/src/bootstrap.mjs +17 -0
- package/src/commander.ts +2 -2
- package/src/filesystem/calculateTreeHash.ts +4 -1
- package/src/bootstrap.sh +0 -26
package/.github/workflows/ci.yml
CHANGED
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
# About Nosto
|
|
2
|
-
|
|
3
|
-
If you are unfamiliar with Nosto as a company, you are welcome to visit out homepage at [https://nosto.com/](https://www.nosto.com/).
|
|
4
|
-
|
|
5
|
-
If you wish to know more about our tech stack, we publish extensive documentation known as the [Techdocs](https://docs.nosto.com/techdocs).
|
|
6
|
-
|
|
7
1
|
# Nosto CLI Tool
|
|
8
2
|
|
|
9
3
|
A command-line interface to interact with Nosto's backend systems. Primarily aimed at developers and power-users who aim to use more powerful desktop tools for search-template development and (in the future) other features.
|
|
10
4
|
|
|
11
5
|
<img width="862" alt="image" src="https://github.com/user-attachments/assets/d26869d2-cd03-4d04-a175-d544c45b99b1" />
|
|
12
6
|
|
|
13
|
-
|
|
7
|
+
# About Nosto
|
|
8
|
+
|
|
9
|
+
If you are unfamiliar with Nosto as a company, you are welcome to visit our homepage at [https://nosto.com/](https://www.nosto.com/).
|
|
10
|
+
|
|
11
|
+
If you wish to know more about our tech stack, we publish extensive documentation known as the [Techdocs](https://docs.nosto.com/techdocs).
|
|
12
|
+
|
|
13
|
+
# Usage
|
|
14
14
|
|
|
15
15
|
Nosto CLI aims to be as user-friendly as CLI tools get. You should be able to get up and running by utilizing the built-in `help` and `setup` commands, but a quick-start guide is also provided here.
|
|
16
16
|
|
|
@@ -123,13 +123,13 @@ With the addition of local builds, the external dependencies are something that
|
|
|
123
123
|
|
|
124
124
|
If you would still like to try your luck with introducing dependencies into a legacy app, we recommend you stick with only build-time dependencies like TypeScript that disappear at runtime. In that case, build your app as you would, and point the CLI's build to the output folder.
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
# Development
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
## Testing
|
|
129
129
|
|
|
130
130
|
This project uses [Vitest](https://vitest.dev/) as the test runner. Tests are organized under the `test/` directory mirroring the structure of `src/`.
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
### Available scripts
|
|
133
133
|
|
|
134
134
|
```bash
|
|
135
135
|
# Run tests once
|
|
@@ -151,4 +151,8 @@ npm run test:coverage
|
|
|
151
151
|
|
|
152
152
|
Running `nosto st push` after `nosto st dev` without changing any files will stop early with the "No files to push" message due to the hashing mechanism not taking the pushed paths into account properly.
|
|
153
153
|
|
|
154
|
-
**Workaround**: Use `nosto st push -f` or change any of the files to update the hash.
|
|
154
|
+
**Workaround**: Use `nosto st push -f` or change any of the files to update the hash.
|
|
155
|
+
|
|
156
|
+
## Contributions
|
|
157
|
+
|
|
158
|
+
We welcome both internal and external contributions to this project! Feel free to request bugfixes, open issues or PRs for review. Nosto is actively maintaining this project, and we will process your contributions as soon as possible.
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosto/nosto-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"main": "./src/index.ts",
|
|
5
5
|
"bin": {
|
|
6
|
-
"nosto": "./src/bootstrap.
|
|
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
|
|
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" "$@"
|