create-faas-app 1.6.0 → 1.7.0
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/dist/index.js +16 -17
- package/dist/index.mjs +16 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ async function action(options = {}) {
|
|
|
37
37
|
if (!answers.name)
|
|
38
38
|
return;
|
|
39
39
|
fs.mkdirSync(answers.name);
|
|
40
|
+
const runtime = process.versions.bun ? "bun" : "npm";
|
|
40
41
|
fs.writeFileSync(
|
|
41
42
|
path.join(answers.name, "faas.yaml"),
|
|
42
43
|
`defaults:
|
|
@@ -51,7 +52,7 @@ production:
|
|
|
51
52
|
path.join(answers.name, "package.json"),
|
|
52
53
|
`{
|
|
53
54
|
"name": "${answers.name}",
|
|
54
|
-
"version": "
|
|
55
|
+
"version": "1.0.0",
|
|
55
56
|
"private": true,
|
|
56
57
|
"scripts": {
|
|
57
58
|
"serve": "faas server",
|
|
@@ -127,19 +128,17 @@ coverage/
|
|
|
127
128
|
}
|
|
128
129
|
`
|
|
129
130
|
);
|
|
130
|
-
child_process.execSync(`cd ${answers.name} &&
|
|
131
|
+
child_process.execSync(`cd ${answers.name} && ${runtime} install`, { stdio: "inherit" });
|
|
131
132
|
if (answers.example) {
|
|
132
133
|
fs.writeFileSync(
|
|
133
134
|
path.join(answers.name, "index.func.ts"),
|
|
134
135
|
`import { useFunc } from '@faasjs/func'
|
|
135
136
|
import { useHttp } from '@faasjs/http'
|
|
136
137
|
|
|
137
|
-
export default useFunc(
|
|
138
|
-
const http useHttp<{ name: string }>()
|
|
138
|
+
export default useFunc(() => {
|
|
139
|
+
const http = useHttp<{ name: string }>()
|
|
139
140
|
|
|
140
|
-
return async
|
|
141
|
-
return 'Hello, ' + http.params.name
|
|
142
|
-
}
|
|
141
|
+
return async () => \`Hello, \${http.params.name}\`
|
|
143
142
|
})
|
|
144
143
|
`
|
|
145
144
|
);
|
|
@@ -147,10 +146,11 @@ export default useFunc(function () {
|
|
|
147
146
|
fs.writeFileSync(
|
|
148
147
|
path.join(answers.name, "__tests__", "index.test.ts"),
|
|
149
148
|
`import { test } from '@faasjs/test'
|
|
149
|
+
import Func from '../index.func'
|
|
150
150
|
|
|
151
|
-
describe('hello',
|
|
152
|
-
it('should work', async
|
|
153
|
-
const func = test(
|
|
151
|
+
describe('hello', () => {
|
|
152
|
+
it('should work', async () => {
|
|
153
|
+
const func = test(Func)
|
|
154
154
|
|
|
155
155
|
const { statusCode, data } = await func.JSONhandler<string>({ name: 'world' })
|
|
156
156
|
|
|
@@ -160,20 +160,19 @@ describe('hello', function () {
|
|
|
160
160
|
})
|
|
161
161
|
`
|
|
162
162
|
);
|
|
163
|
-
|
|
163
|
+
if (runtime === "bun") {
|
|
164
|
+
child_process.execSync(`cd ${answers.name} && bun test`, { stdio: "inherit" });
|
|
165
|
+
} else
|
|
166
|
+
child_process.execSync(`cd ${answers.name} && npm run test`, { stdio: "inherit" });
|
|
164
167
|
}
|
|
165
168
|
}
|
|
166
169
|
function action_default(program) {
|
|
167
|
-
program.description("
|
|
168
|
-
console.log(`
|
|
169
|
-
Examples:
|
|
170
|
-
npx create-faas-app`);
|
|
171
|
-
}).option("--name <name>", "\u9879\u76EE\u540D\u5B57").action(action);
|
|
170
|
+
program.description("Create a new faas app").on("--help", () => console.log("Examples:\nnpx create-faas-app")).option("--name <name>", "Project name").action(action);
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
// src/index.ts
|
|
175
174
|
var commander = new commander$1.Command();
|
|
176
|
-
commander.storeOptionsAsProperties(false).allowUnknownOption(true).
|
|
175
|
+
commander.storeOptionsAsProperties(false).allowUnknownOption(true).name("create-faas-app");
|
|
177
176
|
action_default(commander);
|
|
178
177
|
async function main() {
|
|
179
178
|
try {
|
package/dist/index.mjs
CHANGED
|
@@ -35,6 +35,7 @@ async function action(options = {}) {
|
|
|
35
35
|
if (!answers.name)
|
|
36
36
|
return;
|
|
37
37
|
mkdirSync(answers.name);
|
|
38
|
+
const runtime = process.versions.bun ? "bun" : "npm";
|
|
38
39
|
writeFileSync(
|
|
39
40
|
join(answers.name, "faas.yaml"),
|
|
40
41
|
`defaults:
|
|
@@ -49,7 +50,7 @@ production:
|
|
|
49
50
|
join(answers.name, "package.json"),
|
|
50
51
|
`{
|
|
51
52
|
"name": "${answers.name}",
|
|
52
|
-
"version": "
|
|
53
|
+
"version": "1.0.0",
|
|
53
54
|
"private": true,
|
|
54
55
|
"scripts": {
|
|
55
56
|
"serve": "faas server",
|
|
@@ -125,19 +126,17 @@ coverage/
|
|
|
125
126
|
}
|
|
126
127
|
`
|
|
127
128
|
);
|
|
128
|
-
execSync(`cd ${answers.name} &&
|
|
129
|
+
execSync(`cd ${answers.name} && ${runtime} install`, { stdio: "inherit" });
|
|
129
130
|
if (answers.example) {
|
|
130
131
|
writeFileSync(
|
|
131
132
|
join(answers.name, "index.func.ts"),
|
|
132
133
|
`import { useFunc } from '@faasjs/func'
|
|
133
134
|
import { useHttp } from '@faasjs/http'
|
|
134
135
|
|
|
135
|
-
export default useFunc(
|
|
136
|
-
const http useHttp<{ name: string }>()
|
|
136
|
+
export default useFunc(() => {
|
|
137
|
+
const http = useHttp<{ name: string }>()
|
|
137
138
|
|
|
138
|
-
return async
|
|
139
|
-
return 'Hello, ' + http.params.name
|
|
140
|
-
}
|
|
139
|
+
return async () => \`Hello, \${http.params.name}\`
|
|
141
140
|
})
|
|
142
141
|
`
|
|
143
142
|
);
|
|
@@ -145,10 +144,11 @@ export default useFunc(function () {
|
|
|
145
144
|
writeFileSync(
|
|
146
145
|
join(answers.name, "__tests__", "index.test.ts"),
|
|
147
146
|
`import { test } from '@faasjs/test'
|
|
147
|
+
import Func from '../index.func'
|
|
148
148
|
|
|
149
|
-
describe('hello',
|
|
150
|
-
it('should work', async
|
|
151
|
-
const func = test(
|
|
149
|
+
describe('hello', () => {
|
|
150
|
+
it('should work', async () => {
|
|
151
|
+
const func = test(Func)
|
|
152
152
|
|
|
153
153
|
const { statusCode, data } = await func.JSONhandler<string>({ name: 'world' })
|
|
154
154
|
|
|
@@ -158,20 +158,19 @@ describe('hello', function () {
|
|
|
158
158
|
})
|
|
159
159
|
`
|
|
160
160
|
);
|
|
161
|
-
|
|
161
|
+
if (runtime === "bun") {
|
|
162
|
+
execSync(`cd ${answers.name} && bun test`, { stdio: "inherit" });
|
|
163
|
+
} else
|
|
164
|
+
execSync(`cd ${answers.name} && npm run test`, { stdio: "inherit" });
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
167
|
function action_default(program) {
|
|
165
|
-
program.description("
|
|
166
|
-
console.log(`
|
|
167
|
-
Examples:
|
|
168
|
-
npx create-faas-app`);
|
|
169
|
-
}).option("--name <name>", "\u9879\u76EE\u540D\u5B57").action(action);
|
|
168
|
+
program.description("Create a new faas app").on("--help", () => console.log("Examples:\nnpx create-faas-app")).option("--name <name>", "Project name").action(action);
|
|
170
169
|
}
|
|
171
170
|
|
|
172
171
|
// src/index.ts
|
|
173
172
|
var commander = new Command();
|
|
174
|
-
commander.storeOptionsAsProperties(false).allowUnknownOption(true).
|
|
173
|
+
commander.storeOptionsAsProperties(false).allowUnknownOption(true).name("create-faas-app");
|
|
175
174
|
action_default(commander);
|
|
176
175
|
async function main() {
|
|
177
176
|
try {
|