-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPM testing #4
Merged
Merged
NPM testing #4
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
32fa0f8
Add eslint extractor
ColinMcNeil f3d96fd
Add npm runbook test
ColinMcNeil 67aada1
Improve multi-runbook support
ColinMcNeil 5e5be63
Add node root generation
ColinMcNeil b8e1a35
fix bug with invalid JSON
ColinMcNeil 9c037c6
Add fallback for default node version
ColinMcNeil 793c184
Add x-platform builds
ColinMcNeil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,41 @@ | ||
You are an assistant who specializes in making runbooks for NPM projects, | ||
allowing any developer to quickly run a docker project locally for development. | ||
You are an assistant who specializes in making runbooks for NPM projects, allowing any developer to quickly run a docker project locally for development. | ||
|
||
Since you are an expert and know about their project, be definitive about recommendations. | ||
|
||
A runbook for an npm project contains the following steps: | ||
A runbook for an npm project contains the following: | ||
|
||
# Setup: | ||
|
||
NVM: | ||
Check for NVM or install it with the system's package manager. | ||
Example: | ||
```sh | ||
brew install nvm | ||
``` | ||
|
||
Node and NPM: | ||
Prepare node using nvm, and select the correct package manager | ||
|
||
Run Package Manager: | ||
Depending on npm vs yarn, run an install | ||
|
||
# Run: | ||
Analyze package.json for scripts. | ||
Then, for each node root, you need to do the following: | ||
|
||
# Node Root | ||
|
||
{{#project.node_roots}} | ||
The project has a node root package.json at {{path}} with the contents {{content}}. | ||
Because there is already a root, the project does not need to be converted to npm. | ||
{{/project.node_roots}} | ||
{{^project.node_roots}} | ||
The project does not have a node root, so the user should run `npm init` | ||
{{/project.node_roots}} | ||
Add a block to cd into the node root | ||
|
||
```sh | ||
cd $node_root | ||
``` | ||
|
||
Node and NPM: | ||
Prepare node using nvm, and select the correct package manager. | ||
Example: | ||
```sh | ||
nvm use 20 | ||
``` | ||
|
||
{{#project.version_artifacts}} | ||
The project has a version declaration file {{path}} with the contents {{content}} | ||
{{/project.version_artifacts}} | ||
{{^project.version_artifacts}} | ||
The project does not have any version artifacts, so default to latest node LTS | ||
{{/project.version_artifacts}} | ||
|
||
The user has the following top level project files: | ||
|
||
{{#project.files}} | ||
{{.}} | ||
{{/project.files}} | ||
|
||
If there is a yarn.lock, use `yarn` in place of npm commands. | ||
Run Package Manager: | ||
Depending on npm vs yarn, run an install | ||
Example | ||
```sh | ||
yarn install | ||
``` | ||
|
||
Run `npm install` | ||
Run scripts | ||
|
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 |
---|---|---|
@@ -1 +1,26 @@ | ||
I would like to run this node project. | ||
I have the following project open: | ||
|
||
--- Project --- | ||
|
||
My project has these files: | ||
{{#project.files}} | ||
{{.}} | ||
{{/project.files}} | ||
|
||
If you see that I have a yarn.lock, please use `yarn` in place of npm commands. | ||
|
||
{{#project.node_roots}} | ||
--- Node Root --- | ||
My project has a node root package.json at {{path}} and uses node version {{version}}. | ||
The node root has the following scripts | ||
{{scripts}} | ||
----------------- | ||
{{/project.node_roots}} | ||
{{^project.node_roots}} | ||
The project does not have a node root, so help me run `npm init` | ||
{{/project.node_roots}} | ||
|
||
Please generate a runbook for me. | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,15 +1,17 @@ | ||
FROM ubuntu:20.04 | ||
FROM alpine:3.20 | ||
|
||
WORKDIR /app | ||
# Give me bash | ||
RUN apk add --no-cache bash | ||
|
||
RUN <<EOF | ||
cat > /app/run.sh <<'EOF2' | ||
#!/bin/bash | ||
VOLUME /project | ||
|
||
echo '{"project": {"node_roots": [{"path": "package.json", "content": "some stuff"}]}}' | ||
EOF2 | ||
chmod 755 /app/run.sh | ||
EOF | ||
WORKDIR / | ||
|
||
COPY ./scripts/build-node-roots.sh /build-node-roots.sh | ||
|
||
# MAke the thing executable | ||
RUN chmod +x build-node-roots.sh | ||
|
||
COPY ./scripts/payload.json /payload.json | ||
# when the container is running the project is mounted at /project read-only | ||
ENTRYPOINT ["/app/run.sh"] | ||
ENTRYPOINT ["/build-node-roots.sh"] |
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,7 @@ | ||
#!/bin/bash | ||
# Echo JSON with project.node_roots[] | ||
|
||
cat payload.json | ||
|
||
# Use JQ to get scripts | ||
# jq -r '.project.node_roots[]' payload.json |
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,45 @@ | ||
{ | ||
ColinMcNeil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"project": { | ||
"node_roots": [ | ||
{ | ||
"path": "client/package.json", | ||
"version": "18", | ||
"scripts": { | ||
"vscode:prepublish": "yarn run compile", | ||
"compile": "tsc -p ./", | ||
"watch": "tsc -watch -p ./", | ||
"pretest": "yarn run compile && yarn run lint", | ||
"lint": "eslint src --ext ts", | ||
"test": "vscode-test", | ||
"package": "vsce package" | ||
} | ||
}, | ||
{ | ||
"path": "client/desktop-ui/package.json", | ||
"version": "18", | ||
"scripts": { | ||
"vscode:prepublish": "yarn run compile", | ||
"compile": "tsc -p ./", | ||
"watch": "tsc -watch -p ./", | ||
"pretest": "yarn run compile && yarn run lint", | ||
"lint": "eslint src --ext ts", | ||
"test": "vscode-test", | ||
"package": "vsce package" | ||
} | ||
}, | ||
{ | ||
"path": "client/desktop/package.json", | ||
"version": "20", | ||
"scripts": { | ||
"vscode:prepublish": "yarn run compile", | ||
"compile": "tsc -p ./", | ||
"watch": "tsc -watch -p ./", | ||
"pretest": "yarn run compile && yarn run lint", | ||
"lint": "eslint src --ext ts", | ||
"test": "vscode-test", | ||
"package": "vsce package" | ||
} | ||
} | ||
] | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how these are actionable without an underlying kernel that can maintain this between code blocks. Maybe this is just something we have to track as potential feedback and look for signals that users want us to solve this?