Skip to content

Commit 048cb82

Browse files
committed
feat: add support for yarn
Signed-off-by: Thorsten Hans <[email protected]>
1 parent f91b98f commit 048cb82

File tree

16 files changed

+56
-30
lines changed

16 files changed

+56
-30
lines changed
+23-19
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
{
2-
"name": "{{project-name | kebab_case}}",
3-
"version": "1.0.0",
4-
"description": "{{project-description}}",
5-
"main": "index.js",
6-
"scripts": {
2+
"name": "{{project-name | kebab_case}}",
3+
"version": "1.0.0",
4+
"description": "{{project-description}}",
5+
"main": "index.js",
6+
"scripts": {
7+
{%- if package-manager == "npm" -%}
78
"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 %}",
9+
{%- else -%}
10+
"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 %}",
11+
{%- endif -%}
812
"test": "echo \"Error: no test specified\" && exit 1",
9-
"postinstall": "knitwit"
10-
},
11-
"keywords": [],
12-
"author": "",
13-
"license": "ISC",
14-
"devDependencies": {
15-
"mkdirp": "^3.0.1",
16-
"webpack": "^5.74.0",
17-
"webpack-cli": "^4.10.0"
18-
},
19-
"dependencies": {
20-
"@fermyon/spin-sdk": "^2.3.0"
21-
}
22-
}
13+
"postinstall": "knitwit"
14+
},
15+
"keywords": [],
16+
"author": "",
17+
"license": "ISC",
18+
"devDependencies": {
19+
"mkdirp": "^3.0.1",
20+
"webpack": "^5.74.0",
21+
"webpack-cli": "^4.10.0"
22+
},
23+
"dependencies": {
24+
"@fermyon/spin-sdk": "^2.3.0"
25+
}
26+
}

templates/http-js/content/spin.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ component = "{{project-name | kebab_case}}"
1313
[component.{{project-name | kebab_case}}]
1414
source = "target/{{project-name | kebab_case}}.wasm"
1515
exclude_files = ["**/node_modules"]
16+
allowed_outbound_hosts = []
17+
1618
[component.{{project-name | kebab_case}}.build]
17-
command = "npm run build"
18-
watch = ["src/**/*.ts", "package.json"]
19+
command = "{{ package-manager}} run build"
20+
watch = ["src/**/*.ts", "package.json"]
21+

templates/http-js/metadata/snippets/component.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ source = "{{ output-path }}/target/{{project-name | kebab_case}}.wasm"
77
allowed_outbound_hosts = []
88

99
[component.{{project-name | kebab_case}}.build]
10-
command = "npm run build"
10+
command = "{{ package-manager }} run build"
1111
workdir = "{{ output-path }}"

templates/http-js/metadata/spin-template.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ component = "component.txt"
1111
project-description = { type = "string", prompt = "Description", default = "" }
1212
http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" }
1313
enable-aot = { type = "string", prompt = "Enable AoT Compilation [y/N]", default = "N", pattern = "^[yYnN]$" }
14+
package-manager = { type = "string", prompt = "Which package manager would you like to use (npm|yarn)", default = "npm", pattern = "^(npm|yarn)$" }

templates/http-ts/content/package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
"description": "{{project-description}}",
55
"main": "index.js",
66
"scripts": {
7-
"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 %}",
7+
{%- if package-manager == "npm" -%}
8+
"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 %}",
9+
{%- else -%}
10+
"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 %}",
11+
{%- endif -%}
812
"test": "echo \"Error: no test specified\" && exit 1",
913
"postinstall": "knitwit"
1014
},

templates/http-ts/content/spin.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ component = "{{project-name | kebab_case}}"
1313
[component.{{project-name | kebab_case}}]
1414
source = "target/{{project-name | kebab_case}}.wasm"
1515
exclude_files = ["**/node_modules"]
16+
1617
[component.{{project-name | kebab_case}}.build]
17-
command = "npm run build"
18-
watch = ["src/**/*.ts", "package.json"]
18+
command = "{{ package-manager }} run build"
19+
watch = ["src/**/*.ts", "package.json"]

templates/http-ts/metadata/snippets/component.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ source = "{{ output-path }}/target/{{project-name | kebab_case}}.wasm"
77
allowed_outbound_hosts = []
88

99
[component.{{project-name | kebab_case}}.build]
10-
command = "npm run build"
10+
command = "{{ package-manager }} run build"
1111
workdir = "{{ output-path }}"

templates/http-ts/metadata/spin-template.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ component = "component.txt"
1111
project-description = { type = "string", prompt = "Description", default = "" }
1212
http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" }
1313
enable-aot = { type = "string", prompt = "Enable AoT Compilation [y/N]", default = "N", pattern = "^[yYnN]$" }
14+
package-manager = { type = "string", prompt = "Which package manager would you like to use (npm|yarn)", default = "npm", pattern = "^(npm|yarn)$" }

templates/redis-js/content/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
"description": "{{project-description}}",
55
"main": "index.js",
66
"scripts": {
7+
{%- if package-manager == "npm" -%}
78
"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 %}",
9+
{%- else -%}
10+
"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 %}",
11+
{%- endif -%}
812
"test": "echo \"Error: no test specified\" && exit 1",
913
"postinstall": "knitwit"
1014
},

templates/redis-js/content/spin.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ component = "{{project-name | kebab_case}}"
1616
[component.{{project-name | kebab_case}}]
1717
source = "target/{{project-name | kebab_case}}.wasm"
1818
exclude_files = ["**/node_modules"]
19+
1920
[component.{{project-name | kebab_case}}.build]
20-
command = "npm run build"
21+
command = "{{ package-manager }} run build"
2122
watch = ["src/**/*.ts", "package.json"]

templates/redis-js/metadata/snippets/component.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ component = "{{project-name | kebab_case}}"
66
source = "{{ output-path }}/target/{{project-name | kebab_case}}.wasm"
77
allowed_outbound_hosts = []
88
[component.{{project-name | kebab_case}}.build]
9-
command = "npm run build"
9+
command = "{{ package-manager }} run build"
1010
workdir = "{{ output-path }}"

templates/redis-js/metadata/spin-template.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ project-description = { type = "string", prompt = "Description", default = "" }
1818
redis-address = { type = "string", prompt = "Redis address", default = "redis://localhost:6379" }
1919
redis-channel = { type = "string", prompt = "Redis channel" }
2020
enable-aot = { type = "string", prompt = "Enable AoT Compilation [y/N]", default = "N", pattern = "^[yYnN]$" }
21+
package-manager = { type = "string", prompt = "Which package manager would you like to use (npm|yarn)", default = "npm", pattern = "^(npm|yarn)$" }

templates/redis-ts/content/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
"description": "{{project-description}}",
55
"main": "index.js",
66
"scripts": {
7+
{%- if package-manager == "npm" -%}
78
"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 %}",
9+
{%- else -%}
10+
"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 %}",
11+
{%- endif -%}
812
"test": "echo \"Error: no test specified\" && exit 1",
913
"postinstall": "knitwit"
1014
},

templates/redis-ts/content/spin.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ component = "{{project-name | kebab_case}}"
1616
[component.{{project-name | kebab_case}}]
1717
source = "target/{{project-name | kebab_case}}.wasm"
1818
exclude_files = ["**/node_modules"]
19+
1920
[component.{{project-name | kebab_case}}.build]
20-
command = "npm run build"
21+
command = "{{ package-manager }} run build"
2122
watch = ["src/**/*.ts", "package.json"]

templates/redis-ts/metadata/snippets/component.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ component = "{{project-name | kebab_case}}"
66
source = "{{ output-path }}/target/{{project-name | kebab_case}}.wasm"
77
allowed_outbound_hosts = []
88
[component.{{project-name | kebab_case}}.build]
9-
command = "npm run build"
9+
command = "{{ package-manager }} run build"
1010
workdir = "{{ output-path }}"

templates/redis-ts/metadata/spin-template.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ project-description = { type = "string", prompt = "Description", default = "" }
1818
redis-address = { type = "string", prompt = "Redis address", default = "redis://localhost:6379" }
1919
redis-channel = { type = "string", prompt = "Redis channel" }
2020
enable-aot = { type = "string", prompt = "Enable AoT Compilation [y/N]", default = "N", pattern = "^[yYnN]$" }
21+
package-manager = { type = "string", prompt = "Which package manager would you like to use (npm|yarn)", default = "npm", pattern = "^(npm|yarn)$" }

0 commit comments

Comments
 (0)