Skip to content
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

[templates]: Add support for yarn #305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions templates/http-js/content/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
{
"name": "{{project-name | kebab_case}}",
"version": "1.0.0",
"description": "{{project-description}}",
"main": "index.js",
"scripts": {
"name": "{{project-name | kebab_case}}",
"version": "1.0.0",
"description": "{{project-description}}",
"main": "index.js",
"scripts": {
{%- if package-manager == "npm" -%}
"build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -d combined-wit -n combined -o target/{{project-name | kebab_case}}.wasm {% if enable-aot == 'y' or enable-aot == 'Y' %}--aot{% endif %}",
{%- else -%}
"build": "yarn exec webpack -- --mode=production && yarn exec mkdirp -- target && yarn exec j2w -- -i dist.js -d combined-wit -n combined -o target/{{project-name | kebab_case}}.wasm {% if enable-aot == 'y' or enable-aot == 'Y' %}--aot{% endif %}",
{%- endif -%}
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "knitwit"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"mkdirp": "^3.0.1",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@fermyon/spin-sdk": "^2.3.0"
}
}
"postinstall": "knitwit"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"mkdirp": "^3.0.1",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@fermyon/spin-sdk": "^2.3.0"
}
}
7 changes: 5 additions & 2 deletions templates/http-js/content/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ component = "{{project-name | kebab_case}}"
[component.{{project-name | kebab_case}}]
source = "target/{{project-name | kebab_case}}.wasm"
exclude_files = ["**/node_modules"]
allowed_outbound_hosts = []

[component.{{project-name | kebab_case}}.build]
command = "npm run build"
watch = ["src/**/*.ts", "package.json"]
command = "{{ package-manager}} run build"
watch = ["src/**/*.ts", "package.json"]

2 changes: 1 addition & 1 deletion templates/http-js/metadata/snippets/component.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ source = "{{ output-path }}/target/{{project-name | kebab_case}}.wasm"
allowed_outbound_hosts = []

[component.{{project-name | kebab_case}}.build]
command = "npm run build"
command = "{{ package-manager }} run build"
workdir = "{{ output-path }}"
1 change: 1 addition & 0 deletions templates/http-js/metadata/spin-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ component = "component.txt"
project-description = { type = "string", prompt = "Description", default = "" }
http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" }
enable-aot = { type = "string", prompt = "Enable AoT Compilation [y/N]", default = "N", pattern = "^[yYnN]$" }
package-manager = { type = "string", prompt = "Which package manager would you like to use (npm|yarn)", default = "npm", pattern = "^(npm|yarn)$" }
6 changes: 5 additions & 1 deletion templates/http-ts/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"description": "{{project-description}}",
"main": "index.js",
"scripts": {
"build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -d combined-wit -n combined -o target/{{ project-name | kebab_case }}.wasm {% if enable-aot == 'y' or enable-aot == 'Y' %}--aot{% endif %}",
{%- if package-manager == "npm" -%}
"build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -d combined-wit -n combined -o target/{{project-name | kebab_case}}.wasm {% if enable-aot == 'y' or enable-aot == 'Y' %}--aot{% endif %}",
{%- else -%}
"build": "yarn exec webpack -- --mode=production && yarn exec mkdirp -- target && yarn exec j2w -- -i dist.js -d combined-wit -n combined -o target/{{project-name | kebab_case}}.wasm {% if enable-aot == 'y' or enable-aot == 'Y' %}--aot{% endif %}",
{%- endif -%}
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "knitwit"
},
Expand Down
5 changes: 3 additions & 2 deletions templates/http-ts/content/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ component = "{{project-name | kebab_case}}"
[component.{{project-name | kebab_case}}]
source = "target/{{project-name | kebab_case}}.wasm"
exclude_files = ["**/node_modules"]

[component.{{project-name | kebab_case}}.build]
command = "npm run build"
watch = ["src/**/*.ts", "package.json"]
command = "{{ package-manager }} run build"
watch = ["src/**/*.ts", "package.json"]
2 changes: 1 addition & 1 deletion templates/http-ts/metadata/snippets/component.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ source = "{{ output-path }}/target/{{project-name | kebab_case}}.wasm"
allowed_outbound_hosts = []

[component.{{project-name | kebab_case}}.build]
command = "npm run build"
command = "{{ package-manager }} run build"
workdir = "{{ output-path }}"
1 change: 1 addition & 0 deletions templates/http-ts/metadata/spin-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ component = "component.txt"
project-description = { type = "string", prompt = "Description", default = "" }
http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" }
enable-aot = { type = "string", prompt = "Enable AoT Compilation [y/N]", default = "N", pattern = "^[yYnN]$" }
package-manager = { type = "string", prompt = "Which package manager would you like to use (npm|yarn)", default = "npm", pattern = "^(npm|yarn)$" }
4 changes: 4 additions & 0 deletions templates/redis-js/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"description": "{{project-description}}",
"main": "index.js",
"scripts": {
{%- if package-manager == "npm" -%}
"build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -d combined-wit -n combined -o target/{{project-name | kebab_case}}.wasm {% if enable-aot == 'y' or enable-aot == 'Y' %}--aot{% endif %}",
{%- else -%}
"build": "yarn exec webpack -- --mode=production && yarn exec mkdirp -- target && yarn exec j2w -- -i dist.js -d combined-wit -n combined -o target/{{project-name | kebab_case}}.wasm {% if enable-aot == 'y' or enable-aot == 'Y' %}--aot{% endif %}",
{%- endif -%}
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "knitwit"
},
Expand Down
3 changes: 2 additions & 1 deletion templates/redis-js/content/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ component = "{{project-name | kebab_case}}"
[component.{{project-name | kebab_case}}]
source = "target/{{project-name | kebab_case}}.wasm"
exclude_files = ["**/node_modules"]

[component.{{project-name | kebab_case}}.build]
command = "npm run build"
command = "{{ package-manager }} run build"
watch = ["src/**/*.ts", "package.json"]
2 changes: 1 addition & 1 deletion templates/redis-js/metadata/snippets/component.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ component = "{{project-name | kebab_case}}"
source = "{{ output-path }}/target/{{project-name | kebab_case}}.wasm"
allowed_outbound_hosts = []
[component.{{project-name | kebab_case}}.build]
command = "npm run build"
command = "{{ package-manager }} run build"
workdir = "{{ output-path }}"
1 change: 1 addition & 0 deletions templates/redis-js/metadata/spin-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ project-description = { type = "string", prompt = "Description", default = "" }
redis-address = { type = "string", prompt = "Redis address", default = "redis://localhost:6379" }
redis-channel = { type = "string", prompt = "Redis channel" }
enable-aot = { type = "string", prompt = "Enable AoT Compilation [y/N]", default = "N", pattern = "^[yYnN]$" }
package-manager = { type = "string", prompt = "Which package manager would you like to use (npm|yarn)", default = "npm", pattern = "^(npm|yarn)$" }
4 changes: 4 additions & 0 deletions templates/redis-ts/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"description": "{{project-description}}",
"main": "index.js",
"scripts": {
{%- if package-manager == "npm" -%}
"build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -d combined-wit -n combined -o target/{{project-name | kebab_case}}.wasm {% if enable-aot == 'y' or enable-aot == 'Y' %}--aot{% endif %}",
{%- else -%}
"build": "yarn exec webpack -- --mode=production && yarn exec mkdirp -- target && yarn exec j2w -- -i dist.js -d combined-wit -n combined -o target/{{project-name | kebab_case}}.wasm {% if enable-aot == 'y' or enable-aot == 'Y' %}--aot{% endif %}",
{%- endif -%}
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "knitwit"
},
Expand Down
3 changes: 2 additions & 1 deletion templates/redis-ts/content/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ component = "{{project-name | kebab_case}}"
[component.{{project-name | kebab_case}}]
source = "target/{{project-name | kebab_case}}.wasm"
exclude_files = ["**/node_modules"]

[component.{{project-name | kebab_case}}.build]
command = "npm run build"
command = "{{ package-manager }} run build"
watch = ["src/**/*.ts", "package.json"]
2 changes: 1 addition & 1 deletion templates/redis-ts/metadata/snippets/component.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ component = "{{project-name | kebab_case}}"
source = "{{ output-path }}/target/{{project-name | kebab_case}}.wasm"
allowed_outbound_hosts = []
[component.{{project-name | kebab_case}}.build]
command = "npm run build"
command = "{{ package-manager }} run build"
workdir = "{{ output-path }}"
1 change: 1 addition & 0 deletions templates/redis-ts/metadata/spin-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ project-description = { type = "string", prompt = "Description", default = "" }
redis-address = { type = "string", prompt = "Redis address", default = "redis://localhost:6379" }
redis-channel = { type = "string", prompt = "Redis channel" }
enable-aot = { type = "string", prompt = "Enable AoT Compilation [y/N]", default = "N", pattern = "^[yYnN]$" }
package-manager = { type = "string", prompt = "Which package manager would you like to use (npm|yarn)", default = "npm", pattern = "^(npm|yarn)$" }
Loading