create-faas-app 2.0.0 → 2.2.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/README.md CHANGED
@@ -7,6 +7,10 @@ Quick way to create a FaasJS project.
7
7
 
8
8
  ## Usage
9
9
 
10
- ```sh
11
- npx create-faas-app
10
+ ```bash
11
+ # use npm
12
+ npx create-faas-app --name faasjs
13
+
14
+ # use bun
15
+ bunx create-faas-app --name faasjs
12
16
  ```
package/dist/index.js CHANGED
@@ -27,13 +27,6 @@ async function action(options = {}) {
27
27
  initial: "faasjs",
28
28
  validate: Validator.name
29
29
  }).then((res) => res.value);
30
- if (typeof answers.example === "undefined")
31
- answers.example = await enquirer.prompt({
32
- type: "confirm",
33
- name: "value",
34
- message: "Add example files",
35
- initial: true
36
- }).then((res) => res.value);
37
30
  if (!answers.name)
38
31
  return;
39
32
  fs.mkdirSync(answers.name);
@@ -129,10 +122,9 @@ coverage/
129
122
  `
130
123
  );
131
124
  child_process.execSync(`cd ${answers.name} && ${runtime} install`, { stdio: "inherit" });
132
- if (answers.example) {
133
- fs.writeFileSync(
134
- path.join(answers.name, "index.func.ts"),
135
- `import { useFunc } from '@faasjs/func'
125
+ fs.writeFileSync(
126
+ path.join(answers.name, "index.func.ts"),
127
+ `import { useFunc } from '@faasjs/func'
136
128
  import { useHttp } from '@faasjs/http'
137
129
 
138
130
  export default useFunc(() => {
@@ -141,11 +133,11 @@ export default useFunc(() => {
141
133
  return async () => \`Hello, \${http.params.name}\`
142
134
  })
143
135
  `
144
- );
145
- fs.mkdirSync(path.join(answers.name, "__tests__"));
146
- fs.writeFileSync(
147
- path.join(answers.name, "__tests__", "index.test.ts"),
148
- `import { test } from '@faasjs/test'
136
+ );
137
+ fs.mkdirSync(path.join(answers.name, "__tests__"));
138
+ fs.writeFileSync(
139
+ path.join(answers.name, "__tests__", "index.test.ts"),
140
+ `import { test } from '@faasjs/test'
149
141
  import Func from '../index.func'
150
142
 
151
143
  describe('hello', () => {
@@ -159,12 +151,11 @@ describe('hello', () => {
159
151
  })
160
152
  })
161
153
  `
162
- );
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" });
167
- }
154
+ );
155
+ if (runtime === "bun") {
156
+ child_process.execSync(`cd ${answers.name} && bun test`, { stdio: "inherit" });
157
+ } else
158
+ child_process.execSync(`cd ${answers.name} && npm run test`, { stdio: "inherit" });
168
159
  }
169
160
  function action_default(program) {
170
161
  program.description("Create a new faas app").on("--help", () => console.log("Examples:\nnpx create-faas-app")).option("--name <name>", "Project name").action(action);
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Command } from 'commander';
2
2
  import { prompt } from 'enquirer';
3
- import { mkdirSync, writeFileSync, existsSync } from 'fs';
4
- import { join } from 'path';
5
- import { execSync } from 'child_process';
3
+ import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ import { execSync } from 'node:child_process';
6
6
 
7
7
  // src/index.ts
8
8
  var Validator = {
@@ -25,13 +25,6 @@ async function action(options = {}) {
25
25
  initial: "faasjs",
26
26
  validate: Validator.name
27
27
  }).then((res) => res.value);
28
- if (typeof answers.example === "undefined")
29
- answers.example = await prompt({
30
- type: "confirm",
31
- name: "value",
32
- message: "Add example files",
33
- initial: true
34
- }).then((res) => res.value);
35
28
  if (!answers.name)
36
29
  return;
37
30
  mkdirSync(answers.name);
@@ -127,10 +120,9 @@ coverage/
127
120
  `
128
121
  );
129
122
  execSync(`cd ${answers.name} && ${runtime} install`, { stdio: "inherit" });
130
- if (answers.example) {
131
- writeFileSync(
132
- join(answers.name, "index.func.ts"),
133
- `import { useFunc } from '@faasjs/func'
123
+ writeFileSync(
124
+ join(answers.name, "index.func.ts"),
125
+ `import { useFunc } from '@faasjs/func'
134
126
  import { useHttp } from '@faasjs/http'
135
127
 
136
128
  export default useFunc(() => {
@@ -139,11 +131,11 @@ export default useFunc(() => {
139
131
  return async () => \`Hello, \${http.params.name}\`
140
132
  })
141
133
  `
142
- );
143
- mkdirSync(join(answers.name, "__tests__"));
144
- writeFileSync(
145
- join(answers.name, "__tests__", "index.test.ts"),
146
- `import { test } from '@faasjs/test'
134
+ );
135
+ mkdirSync(join(answers.name, "__tests__"));
136
+ writeFileSync(
137
+ join(answers.name, "__tests__", "index.test.ts"),
138
+ `import { test } from '@faasjs/test'
147
139
  import Func from '../index.func'
148
140
 
149
141
  describe('hello', () => {
@@ -157,12 +149,11 @@ describe('hello', () => {
157
149
  })
158
150
  })
159
151
  `
160
- );
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" });
165
- }
152
+ );
153
+ if (runtime === "bun") {
154
+ execSync(`cd ${answers.name} && bun test`, { stdio: "inherit" });
155
+ } else
156
+ execSync(`cd ${answers.name} && npm run test`, { stdio: "inherit" });
166
157
  }
167
158
  function action_default(program) {
168
159
  program.description("Create a new faas app").on("--help", () => console.log("Examples:\nnpx create-faas-app")).option("--name <name>", "Project name").action(action);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-faas-app",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "bin": {