@gasket/plugin-fastify 7.0.0-next.62 → 7.0.0-next.64

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.
Files changed (2) hide show
  1. package/lib/create.js +40 -4
  2. package/package.json +6 -3
package/lib/create.js CHANGED
@@ -2,22 +2,58 @@
2
2
 
3
3
  const { name, version, devDependencies } = require('../package.json');
4
4
 
5
+ /**
6
+ * createTestFiles
7
+ * @property {Files} files - The Gasket Files API.
8
+ * @property {generatorDir} - The directory of the generator.
9
+ * @property {testPlugins} - Array of selected test plugins
10
+ * @property {globIgnore} - Extension pattern to ignore
11
+ */
12
+ function createTestFiles({ files, generatorDir, testPlugins, globIgnore }) {
13
+ if (!testPlugins || testPlugins.length === 0) return;
14
+ const unit = ['jest', 'mocha'];
15
+ const integration = ['cypress'];
16
+ const frameworks = [...unit, ...integration];
17
+ const frameworksRegex = new RegExp(frameworks.join('|'));
18
+
19
+ testPlugins.forEach((testPlugin) => {
20
+ const match = frameworksRegex.exec(testPlugin);
21
+ if (match) {
22
+ const matchedFramework = match[0];
23
+ if (unit.includes(matchedFramework)) {
24
+ files.add(`${generatorDir}/${matchedFramework}/*/${globIgnore}`, `${generatorDir}/${matchedFramework}/**/${globIgnore}`);
25
+ } else {
26
+ files.add(`${generatorDir}/${matchedFramework}/*`, `${generatorDir}/${matchedFramework}/**/*`);
27
+ }
28
+ }
29
+ });
30
+ }
31
+
5
32
  /**
6
33
  * Add files & extend package.json for new apps.
7
34
  * @type {import('@gasket/core').HookHandler<'create'>}
8
35
  */
9
36
  module.exports = async function create(gasket, context) {
37
+ const {
38
+ files,
39
+ typescript,
40
+ testPlugins,
41
+ pkg,
42
+ gasketConfig
43
+ } = context;
10
44
  const generatorDir = `${__dirname}/../generator`;
11
45
 
12
- context.gasketConfig.addPlugin('pluginFastify', name);
46
+ gasketConfig.addPlugin('pluginFastify', name);
13
47
 
14
- context.pkg.add('dependencies', {
48
+ pkg.add('dependencies', {
15
49
  [name]: `^${version}`,
16
50
  fastify: devDependencies.fastify
17
51
  });
18
52
 
19
53
  if ('apiApp' in context && context.apiApp) {
20
- const glob = context.typescript ? '**/*.ts' : '**/*.js';
21
- context.files.add(`${generatorDir}/${glob}`);
54
+ const globIgnore = typescript ? '!(*.js)' : '!(*.ts)';
55
+ files.add(`${generatorDir}/app/**/${globIgnore}`)
56
+
57
+ createTestFiles({ files, generatorDir, testPlugins, globIgnore });
22
58
  }
23
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gasket/plugin-fastify",
3
- "version": "7.0.0-next.62",
3
+ "version": "7.0.0-next.64",
4
4
  "description": "Adds fastify support to your application",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-plugin-fastify",
41
41
  "devDependencies": {
42
- "@gasket/core": "7.0.0-next.62",
42
+ "@gasket/core": "7.0.0-next.64",
43
43
  "cross-env": "^7.0.3",
44
44
  "eslint": "^8.56.0",
45
45
  "eslint-config-godaddy": "^7.1.1",
@@ -71,5 +71,8 @@
71
71
  "eslintIgnore": [
72
72
  "generator"
73
73
  ],
74
- "gitHead": "8d6cf8ef71a549955cbfe9610bb1ee07cc40d96d"
74
+ "jest": {
75
+ "rootDir": "test"
76
+ },
77
+ "gitHead": "b372e6c7768d61d6f3327df008db95a05a489098"
75
78
  }