@taqueria/plugin-jest 0.7.0-rc1 → 0.7.2-rc2

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import {Plugin as $d3MIr$Plugin, Task as $d3MIr$Task, PositionalArg as $d3MIr$PositionalArg, Option as $d3MIr$Option, sendAsyncErr as $d3MIr$sendAsyncErr, noop as $d3MIr$noop, sendAsyncRes as $d3MIr$sendAsyncRes} from "@taqueria/node-sdk";
1
+ import {Plugin as $d3MIr$Plugin, Task as $d3MIr$Task, PositionalArg as $d3MIr$PositionalArg, Option as $d3MIr$Option, sendAsyncErr as $d3MIr$sendAsyncErr, sendAsyncRes as $d3MIr$sendAsyncRes} from "@taqueria/node-sdk";
2
2
  import {SanitizedAbsPath as $d3MIr$SanitizedAbsPath, SanitizedPath as $d3MIr$SanitizedPath} from "@taqueria/node-sdk/types";
3
3
  import {execa as $d3MIr$execa} from "execa";
4
4
  import {stat as $d3MIr$stat, writeFile as $d3MIr$writeFile, mkdir as $d3MIr$mkdir} from "fs/promises";
@@ -49,22 +49,28 @@ const $74485658d1dbcd36$var$execCmd = (cmd, args)=>{
49
49
  });
50
50
  child.stdout?.pipe(process.stdout);
51
51
  child.stderr?.pipe(process.stderr);
52
- return child.then((0, $d3MIr$noop));
52
+ return child;
53
53
  };
54
54
  var $74485658d1dbcd36$export$2e2bcd8739ae039 = async (args)=>{
55
55
  const opts = args;
56
56
  return $74485658d1dbcd36$var$ensurePartitionExists(opts).then((configAbsPath)=>{
57
- if (!opts.init) return opts.testPattern ? $74485658d1dbcd36$var$execCmd("npx", [
58
- "jest",
59
- "-c",
60
- configAbsPath,
61
- "--testPathPattern",
62
- opts.testPattern
63
- ]) : $74485658d1dbcd36$var$execCmd("npx", [
64
- "jest",
65
- "-c",
66
- configAbsPath
67
- ]);
57
+ if (!opts.init) {
58
+ const retval = opts.testPattern ? $74485658d1dbcd36$var$execCmd("npx", [
59
+ "jest",
60
+ "-c",
61
+ configAbsPath,
62
+ "--testPathPattern",
63
+ opts.testPattern
64
+ ]) : $74485658d1dbcd36$var$execCmd("npx", [
65
+ "jest",
66
+ "-c",
67
+ configAbsPath
68
+ ]);
69
+ return retval.then((child)=>{
70
+ if (child.exitCode === 0) return;
71
+ else process.exit(child.exitCode);
72
+ });
73
+ }
68
74
  return (0, $d3MIr$sendAsyncRes)("Initialized successfully.");
69
75
  });
70
76
  };
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AAAA;ACAA;;;;;;AAoBA,MAAM,sCAAgB,GAAG,CAAC,aAA4B,GAAK,CAAC;iBAC3C,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA,GAAA,eAAQ,CAAA,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACrD,CAAC,AAAC;AAEF,MAAM,4CAAsB,GAAG,CAAC,UAA8B,GAAK;IAClE,MAAM,cAAc,GAAG,0CAAoB,CAAC,UAAU,CAAC,AAAC;IACxD,OAAO,CAAA,GAAA,WAAI,CAAA,CAAC,cAAc,CAAC,CACzB,KAAK,CAAC,CAAA,CAAC,GAAI,CAAA,GAAA,gBAAS,CAAA,CAAC,cAAc,EAAE,sCAAgB,CAAC,CAAA,GAAA,eAAQ,CAAA,CAAC,CAAC,CAAC,CACjE,IAAI,CAAC,CAAA,CAAC,GAAI,cAAc,CAAC,CAAC;CAC5B,AAAC;AAEF,MAAM,0CAAoB,GAAG,CAAC,UAA8B,GAC3D,CAAA,GAAA,uBAAgB,CAAA,CAAC,MAAM,CACtB,CAAA,GAAA,WAAI,CAAA,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAC1C,AAAC;AAEH,MAAM,qCAAe,GAAG,CAAC,MAAoB,GAAK;IACjD,OAAO,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC;CAC1C,AAAC;AAEF,MAAM,oCAAc,GAAG,CAAC,gBAAiC,EAAE,iBAAkC,GAA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wCAAK;KACL,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-jest/index.ts","taqueria-plugin-jest/proxy.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport proxy from './proxy';\n\nPlugin.create(() => ({\n\tschema: '0.1',\n\tversion: '0.4.0',\n\talias: 'jest',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test [partition]',\n\t\t\tdescription: 'Setup a directory as a partition to run Jest tests',\n\t\t\taliases: ['jest'],\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'partition',\n\t\t\t\t\tdescription: 'Name of the partition for these tests',\n\t\t\t\t\tdefaultValue: 'tests',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'init',\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tdescription: 'Initializes the partition for Jest',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'testPattern',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdescription: 'Run test files that match the provided pattern',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t],\n\tproxy,\n}), process.argv);\n","import { noop, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { LoadedConfig, RequestArgs, SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';\nimport { execa } from 'execa';\nimport { mkdir, stat, writeFile } from 'fs/promises';\nimport { defaults } from 'jest-config';\nimport { join, relative } from 'path';\n\ntype DefaultConfig = typeof defaults;\n\ninterface CustomConfig extends LoadedConfig.t {\n\treadonly jestTestsRootDir?: string;\n}\n\ninterface Opts extends RequestArgs.ProxyRequestArgs {\n\treadonly config: CustomConfig;\n\treadonly init: boolean;\n\treadonly partition: string;\n\treadonly testPattern: string;\n}\n\nconst getDefaultConfig = (defaultConfig: DefaultConfig) => `\nmodule.exports = ${JSON.stringify(defaults, null, 4)}\n`;\n\nconst ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {\n\tconst jestRootConfig = getRootConfigAbspath(projectDir);\n\treturn stat(jestRootConfig)\n\t\t.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))\n\t\t.then(_ => jestRootConfig);\n};\n\nconst getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>\n\tSanitizedAbsPath.create(\n\t\tjoin(projectDir, '.taq', 'jest.config.js'),\n\t);\n\nconst getTestsRootDir = (config: CustomConfig) => {\n\treturn config.jestTestsRootDir || 'tests';\n};\n\nconst toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `\nconst parentConfig = require('${rootConfigRelPath}')\n\nmodule.exports = {\n ...parentConfig,\n roots: [\n \"${partitionRelpath}\"\n ]\n}\n`;\n\nconst getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);\n\nconst getPartitionConfigAbspath = (partitionDir: string) =>\n\tSanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));\n\nconst createPartition = async (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) =>\n\tensureRootConfigExists(projectDir)\n\t\t.then(_ => stat(partitionDir))\n\t\t.then(stats =>\n\t\t\tstats.isFile()\n\t\t\t\t? sendAsyncErr(`${partitionDir} is an invalid partition directory`)\n\t\t\t\t: stats\n\t\t)\n\t\t.catch(_ => mkdir(partitionDir, { recursive: true }))\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir))\n\t\t.then(partitionCfgAbsPath =>\n\t\t\tstat(partitionCfgAbsPath)\n\t\t\t\t.catch(_ =>\n\t\t\t\t\twriteFile(\n\t\t\t\t\t\tpartitionCfgAbsPath,\n\t\t\t\t\t\ttoPartitionCfg(\n\t\t\t\t\t\t\tSanitizedPath.create(relative(partitionDir, partitionDir)),\n\t\t\t\t\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t)\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir));\n\nconst ensurePartitionExists = (args: Opts) =>\n\targs.partition\n\t\t? createPartition(\n\t\t\tSanitizedAbsPath.create(join(args.projectDir, args.partition)),\n\t\t\targs.projectDir,\n\t\t)\n\t\t: createPartition(\n\t\t\tSanitizedAbsPath.create(\n\t\t\t\tjoin(args.projectDir, getTestsRootDir(args.config)),\n\t\t\t),\n\t\t\targs.projectDir,\n\t\t);\n\nconst execCmd = (cmd: string, args: string[]) => {\n\tconst child = execa(cmd, args, {\n\t\tshell: true,\n\t\treject: false,\n\t\tenv: { FORCE_COLOR: 'true' },\n\t});\n\n\tchild.stdout?.pipe(process.stdout);\n\tchild.stderr?.pipe(process.stderr);\n\n\treturn child.then(noop);\n};\n\nexport default async (args: RequestArgs.ProxyRequestArgs) => {\n\tconst opts = args as Opts;\n\n\treturn ensurePartitionExists(opts)\n\t\t.then(configAbsPath => {\n\t\t\tif (!opts.init) {\n\t\t\t\treturn opts.testPattern\n\t\t\t\t\t? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', opts.testPattern])\n\t\t\t\t\t: execCmd('npx', ['jest', '-c', configAbsPath]);\n\t\t\t}\n\n\t\t\treturn sendAsyncRes('Initialized successfully.');\n\t\t});\n};\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
1
+ {"mappings":";;;;;;;AAAA;ACAA;;;;;;AAoBA,MAAM,sCAAgB,GAAG,CAAC,aAA4B,GAAK,CAAC;iBAC3C,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA,GAAA,eAAQ,CAAA,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACrD,CAAC,AAAC;AAEF,MAAM,4CAAsB,GAAG,CAAC,UAA8B,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AAM,CAAC,IAAO,CAAA;QACpB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,MAAM;QACb,KAAK,EAAE;YACN,CAAA,GAAA,WAAI,CAAA,CAAC,MAAM,CAAC;gBACX,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,kBAAkB;gBAC3B,WAAW,EAAE,oDAAoD;gBACjE,OAAO,EAAE;oBAAC,MAAM;iBAAC;gBACjB,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE;oBACZ,CAAA,GAAA,oBAAa,CAAA,CAAC,MAAM,CAAC;wBACpB,WAAW,EAAE,WAAW;wBACxB,WAAW,EAAE,uCAAuC;wBACpD,YAAY,EAAE,OAAO;wBACrB,IAAI,EAAE,QAAQ;qBACd,CAAC;iBACF;gBACD,OAAO,EAAE;oBACR,CAAA,GAAA,aAAM,CAAA,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,MAAM;wBACZ,SAAS,EAAE,GAAG;wBACd,WAAW,EAAE,oCAAoC;wBACjD,OAAO,EAAE,IAAI;qBACb,CAAC;oBACF,CAAA,GAAA,aAAM,CAAA,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,aAAa;wBACnB,SAAS,EAAE,GAAG;wBACd,WAAW,EAAE,gDAAgD;qBAC7D,CAAC;iBACF;aACD,CAAC;SACF;eACD,wCAAK;KACL,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-jest/index.ts","taqueria-plugin-jest/proxy.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport proxy from './proxy';\n\nPlugin.create(() => ({\n\tschema: '0.1',\n\tversion: '0.4.0',\n\talias: 'jest',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test [partition]',\n\t\t\tdescription: 'Setup a directory as a partition to run Jest tests',\n\t\t\taliases: ['jest'],\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'partition',\n\t\t\t\t\tdescription: 'Name of the partition for these tests',\n\t\t\t\t\tdefaultValue: 'tests',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'init',\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tdescription: 'Initializes the partition for Jest',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'testPattern',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdescription: 'Run test files that match the provided pattern',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t],\n\tproxy,\n}), process.argv);\n","import { noop, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { LoadedConfig, RequestArgs, SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';\nimport { execa } from 'execa';\nimport { mkdir, stat, writeFile } from 'fs/promises';\nimport { defaults } from 'jest-config';\nimport { join, relative } from 'path';\n\ntype DefaultConfig = typeof defaults;\n\ninterface CustomConfig extends LoadedConfig.t {\n\treadonly jestTestsRootDir?: string;\n}\n\ninterface Opts extends RequestArgs.ProxyRequestArgs {\n\treadonly config: CustomConfig;\n\treadonly init: boolean;\n\treadonly partition: string;\n\treadonly testPattern: string;\n}\n\nconst getDefaultConfig = (defaultConfig: DefaultConfig) => `\nmodule.exports = ${JSON.stringify(defaults, null, 4)}\n`;\n\nconst ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {\n\tconst jestRootConfig = getRootConfigAbspath(projectDir);\n\treturn stat(jestRootConfig)\n\t\t.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))\n\t\t.then(_ => jestRootConfig);\n};\n\nconst getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>\n\tSanitizedAbsPath.create(\n\t\tjoin(projectDir, '.taq', 'jest.config.js'),\n\t);\n\nconst getTestsRootDir = (config: CustomConfig) => {\n\treturn config.jestTestsRootDir || 'tests';\n};\n\nconst toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `\nconst parentConfig = require('${rootConfigRelPath}')\n\nmodule.exports = {\n ...parentConfig,\n roots: [\n \"${partitionRelpath}\"\n ]\n}\n`;\n\nconst getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);\n\nconst getPartitionConfigAbspath = (partitionDir: string) =>\n\tSanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));\n\nconst createPartition = async (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) =>\n\tensureRootConfigExists(projectDir)\n\t\t.then(_ => stat(partitionDir))\n\t\t.then(stats =>\n\t\t\tstats.isFile()\n\t\t\t\t? sendAsyncErr(`${partitionDir} is an invalid partition directory`)\n\t\t\t\t: stats\n\t\t)\n\t\t.catch(_ => mkdir(partitionDir, { recursive: true }))\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir))\n\t\t.then(partitionCfgAbsPath =>\n\t\t\tstat(partitionCfgAbsPath)\n\t\t\t\t.catch(_ =>\n\t\t\t\t\twriteFile(\n\t\t\t\t\t\tpartitionCfgAbsPath,\n\t\t\t\t\t\ttoPartitionCfg(\n\t\t\t\t\t\t\tSanitizedPath.create(relative(partitionDir, partitionDir)),\n\t\t\t\t\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t)\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir));\n\nconst ensurePartitionExists = (args: Opts) =>\n\targs.partition\n\t\t? createPartition(\n\t\t\tSanitizedAbsPath.create(join(args.projectDir, args.partition)),\n\t\t\targs.projectDir,\n\t\t)\n\t\t: createPartition(\n\t\t\tSanitizedAbsPath.create(\n\t\t\t\tjoin(args.projectDir, getTestsRootDir(args.config)),\n\t\t\t),\n\t\t\targs.projectDir,\n\t\t);\n\nconst execCmd = (cmd: string, args: string[]) => {\n\tconst child = execa(cmd, args, {\n\t\tshell: true,\n\t\treject: false,\n\t\tenv: { FORCE_COLOR: 'true' },\n\t});\n\n\tchild.stdout?.pipe(process.stdout);\n\tchild.stderr?.pipe(process.stderr);\n\n\treturn child;\n};\n\nexport default async (args: RequestArgs.ProxyRequestArgs) => {\n\tconst opts = args as Opts;\n\n\treturn ensurePartitionExists(opts)\n\t\t.then(configAbsPath => {\n\t\t\tif (!opts.init) {\n\t\t\t\tconst retval = opts.testPattern\n\t\t\t\t\t? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', opts.testPattern])\n\t\t\t\t\t: execCmd('npx', ['jest', '-c', configAbsPath]);\n\t\t\t\treturn retval.then(child => {\n\t\t\t\t\tif (child.exitCode === 0) return;\n\t\t\t\t\telse process.exit(child.exitCode);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn sendAsyncRes('Initialized successfully.');\n\t\t});\n};\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/plugin-jest",
3
- "version": "0.7.0-rc1",
3
+ "version": "0.7.2-rc2",
4
4
  "description": "A plugin for Taqueria providing automated testing using the Jest Testing Framework",
5
5
  "keywords": [
6
6
  "taqueria",
@@ -37,6 +37,7 @@
37
37
  "async-retry": "^1.3.3",
38
38
  "execa": "^6.1.0",
39
39
  "fast-glob": "^3.2.7",
40
+ "jest": "^28.1.0",
40
41
  "jest-cli": "^28.1.0",
41
42
  "jest-config": "^28.1.0"
42
43
  },
package/proxy.ts CHANGED
@@ -101,7 +101,7 @@ const execCmd = (cmd: string, args: string[]) => {
101
101
  child.stdout?.pipe(process.stdout);
102
102
  child.stderr?.pipe(process.stderr);
103
103
 
104
- return child.then(noop);
104
+ return child;
105
105
  };
106
106
 
107
107
  export default async (args: RequestArgs.ProxyRequestArgs) => {
@@ -110,9 +110,13 @@ export default async (args: RequestArgs.ProxyRequestArgs) => {
110
110
  return ensurePartitionExists(opts)
111
111
  .then(configAbsPath => {
112
112
  if (!opts.init) {
113
- return opts.testPattern
113
+ const retval = opts.testPattern
114
114
  ? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', opts.testPattern])
115
115
  : execCmd('npx', ['jest', '-c', configAbsPath]);
116
+ return retval.then(child => {
117
+ if (child.exitCode === 0) return;
118
+ else process.exit(child.exitCode);
119
+ });
116
120
  }
117
121
 
118
122
  return sendAsyncRes('Initialized successfully.');