@taqueria/plugin-jest 0.6.4 → 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,9 +1,9 @@
1
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
- import {SanitizedAbsPath as $d3MIr$SanitizedAbsPath} from "@taqueria/node-sdk/types";
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";
5
5
  import {defaults as $d3MIr$defaults} from "jest-config";
6
- import {join as $d3MIr$join} from "path";
6
+ import {join as $d3MIr$join, relative as $d3MIr$relative} from "path";
7
7
 
8
8
 
9
9
 
@@ -23,13 +23,13 @@ const $74485658d1dbcd36$var$getRootConfigAbspath = (projectDir)=>(0, $d3MIr$Sani
23
23
  const $74485658d1dbcd36$var$getTestsRootDir = (config)=>{
24
24
  return config.jestTestsRootDir || "tests";
25
25
  };
26
- const $74485658d1dbcd36$var$toPartitionCfg = (partitionAbspath, rootConfigAbsPath)=>`
27
- const parentConfig = require('${rootConfigAbsPath}')
26
+ const $74485658d1dbcd36$var$toPartitionCfg = (partitionRelpath, rootConfigRelPath)=>`
27
+ const parentConfig = require('${rootConfigRelPath}')
28
28
 
29
29
  module.exports = {
30
30
  ...parentConfig,
31
31
  roots: [
32
- "${partitionAbspath}"
32
+ "${partitionRelpath}"
33
33
  ]
34
34
  }
35
35
  `;
@@ -37,36 +37,40 @@ const $74485658d1dbcd36$var$getPartitionAbspath = (partitionDir)=>(0, $d3MIr$San
37
37
  const $74485658d1dbcd36$var$getPartitionConfigAbspath = (partitionDir)=>(0, $d3MIr$SanitizedAbsPath).create((0, $d3MIr$join)(partitionDir, "jest.config.js"));
38
38
  const $74485658d1dbcd36$var$createPartition = async (partitionDir, projectDir)=>$74485658d1dbcd36$var$ensureRootConfigExists(projectDir).then((_)=>(0, $d3MIr$stat)(partitionDir)).then((stats)=>stats.isFile() ? (0, $d3MIr$sendAsyncErr)(`${partitionDir} is an invalid partition directory`) : stats).catch((_)=>(0, $d3MIr$mkdir)(partitionDir, {
39
39
  recursive: true
40
- })).then((_)=>$74485658d1dbcd36$var$getPartitionConfigAbspath(partitionDir)).then((partitionCfgAbsPath)=>(0, $d3MIr$stat)(partitionCfgAbsPath).catch((_)=>(0, $d3MIr$writeFile)(partitionCfgAbsPath, $74485658d1dbcd36$var$toPartitionCfg($74485658d1dbcd36$var$getPartitionAbspath(partitionDir), $74485658d1dbcd36$var$getRootConfigAbspath(projectDir))))).then((_)=>$74485658d1dbcd36$var$getPartitionConfigAbspath(partitionDir));
40
+ })).then((_)=>$74485658d1dbcd36$var$getPartitionConfigAbspath(partitionDir)).then((partitionCfgAbsPath)=>(0, $d3MIr$stat)(partitionCfgAbsPath).catch((_)=>(0, $d3MIr$writeFile)(partitionCfgAbsPath, $74485658d1dbcd36$var$toPartitionCfg((0, $d3MIr$SanitizedPath).create((0, $d3MIr$relative)(partitionDir, partitionDir)), (0, $d3MIr$SanitizedPath).create((0, $d3MIr$relative)(partitionDir, $74485658d1dbcd36$var$getRootConfigAbspath(projectDir))))))).then((_)=>$74485658d1dbcd36$var$getPartitionConfigAbspath(partitionDir));
41
41
  const $74485658d1dbcd36$var$ensurePartitionExists = (args)=>args.partition ? $74485658d1dbcd36$var$createPartition((0, $d3MIr$SanitizedAbsPath).create((0, $d3MIr$join)(args.projectDir, args.partition)), args.projectDir) : $74485658d1dbcd36$var$createPartition((0, $d3MIr$SanitizedAbsPath).create((0, $d3MIr$join)(args.projectDir, $74485658d1dbcd36$var$getTestsRootDir(args.config))), args.projectDir);
42
42
  const $74485658d1dbcd36$var$execCmd = (cmd, args)=>{
43
- // console.log([cmd, ...args].join(' '))
44
43
  const child = (0, $d3MIr$execa)(cmd, args, {
45
- reject: false,
46
- buffer: false,
47
- // encoding: null,
48
44
  shell: true,
49
- stdio: "inherit",
45
+ reject: false,
50
46
  env: {
51
47
  FORCE_COLOR: "true"
52
48
  }
53
49
  });
54
- return child.then((_)=>{});
50
+ child.stdout?.pipe(process.stdout);
51
+ child.stderr?.pipe(process.stderr);
52
+ return child;
55
53
  };
56
54
  var $74485658d1dbcd36$export$2e2bcd8739ae039 = async (args)=>{
57
55
  const opts = args;
58
56
  return $74485658d1dbcd36$var$ensurePartitionExists(opts).then((configAbsPath)=>{
59
- if (!opts.init) return opts.testPattern ? $74485658d1dbcd36$var$execCmd("npx", [
60
- "jest",
61
- "-c",
62
- configAbsPath,
63
- "--testPathPattern",
64
- opts.testPattern
65
- ]) : $74485658d1dbcd36$var$execCmd("npx", [
66
- "jest",
67
- "-c",
68
- configAbsPath
69
- ]);
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
+ }
70
74
  return (0, $d3MIr$sendAsyncRes)("Initialized successfully.");
71
75
  });
72
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,CA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C,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 { sendAsyncErr, sendAsyncRes, sendErr } from '@taqueria/node-sdk';\nimport { LoadedConfig, RequestArgs, SanitizedAbsPath } from '@taqueria/node-sdk/types';\nimport { execa } from 'execa';\nimport { mkdir, stat, writeFile } from 'fs/promises';\nimport { defaults } from 'jest-config';\nimport { join } 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 = (partitionAbspath: SanitizedAbsPath.t, rootConfigAbsPath: SanitizedAbsPath.t) => `\nconst parentConfig = require('${rootConfigAbsPath}')\n\nmodule.exports = {\n ...parentConfig,\n roots: [\n \"${partitionAbspath}\"\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\tgetPartitionAbspath(partitionDir),\n\t\t\t\t\t\t\tgetRootConfigAbspath(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\t// console.log([cmd, ...args].join(' '))\n\n\tconst child = execa(cmd, args, {\n\t\treject: false,\n\t\tbuffer: false,\n\t\t// encoding: null,\n\t\tshell: true,\n\t\tstdio: 'inherit',\n\t\tenv: { FORCE_COLOR: 'true' },\n\t});\n\n\treturn child.then(_ => {});\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,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,GAAK,CAAC;8BACrE,EAAE,iBAAiB,CAAC;;;;;SAKzC,EAAE,gBAAgB,CAAC;;;AAG5B,CAAC,AAAC;AAEF,MA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,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.6.4",
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",
@@ -33,10 +33,11 @@
33
33
  "directory": "taqueria-plugin-jest"
34
34
  },
35
35
  "dependencies": {
36
- "@taqueria/node-sdk": "^0.6.2",
36
+ "@taqueria/node-sdk": "^0.7.0-rc1",
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
@@ -1,9 +1,9 @@
1
- import { sendAsyncErr, sendAsyncRes, sendErr } from '@taqueria/node-sdk';
2
- import { LoadedConfig, RequestArgs, SanitizedAbsPath } from '@taqueria/node-sdk/types';
1
+ import { noop, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
2
+ import { LoadedConfig, RequestArgs, SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';
3
3
  import { execa } from 'execa';
4
4
  import { mkdir, stat, writeFile } from 'fs/promises';
5
5
  import { defaults } from 'jest-config';
6
- import { join } from 'path';
6
+ import { join, relative } from 'path';
7
7
 
8
8
  type DefaultConfig = typeof defaults;
9
9
 
@@ -38,13 +38,13 @@ const getTestsRootDir = (config: CustomConfig) => {
38
38
  return config.jestTestsRootDir || 'tests';
39
39
  };
40
40
 
41
- const toPartitionCfg = (partitionAbspath: SanitizedAbsPath.t, rootConfigAbsPath: SanitizedAbsPath.t) => `
42
- const parentConfig = require('${rootConfigAbsPath}')
41
+ const toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `
42
+ const parentConfig = require('${rootConfigRelPath}')
43
43
 
44
44
  module.exports = {
45
45
  ...parentConfig,
46
46
  roots: [
47
- "${partitionAbspath}"
47
+ "${partitionRelpath}"
48
48
  ]
49
49
  }
50
50
  `;
@@ -70,8 +70,8 @@ const createPartition = async (partitionDir: SanitizedAbsPath.t, projectDir: San
70
70
  writeFile(
71
71
  partitionCfgAbsPath,
72
72
  toPartitionCfg(
73
- getPartitionAbspath(partitionDir),
74
- getRootConfigAbspath(projectDir),
73
+ SanitizedPath.create(relative(partitionDir, partitionDir)),
74
+ SanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),
75
75
  ),
76
76
  )
77
77
  )
@@ -92,18 +92,16 @@ const ensurePartitionExists = (args: Opts) =>
92
92
  );
93
93
 
94
94
  const execCmd = (cmd: string, args: string[]) => {
95
- // console.log([cmd, ...args].join(' '))
96
-
97
95
  const child = execa(cmd, args, {
98
- reject: false,
99
- buffer: false,
100
- // encoding: null,
101
96
  shell: true,
102
- stdio: 'inherit',
97
+ reject: false,
103
98
  env: { FORCE_COLOR: 'true' },
104
99
  });
105
100
 
106
- return child.then(_ => {});
101
+ child.stdout?.pipe(process.stdout);
102
+ child.stderr?.pipe(process.stderr);
103
+
104
+ return child;
107
105
  };
108
106
 
109
107
  export default async (args: RequestArgs.ProxyRequestArgs) => {
@@ -112,9 +110,13 @@ export default async (args: RequestArgs.ProxyRequestArgs) => {
112
110
  return ensurePartitionExists(opts)
113
111
  .then(configAbsPath => {
114
112
  if (!opts.init) {
115
- return opts.testPattern
113
+ const retval = opts.testPattern
116
114
  ? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', opts.testPattern])
117
115
  : execCmd('npx', ['jest', '-c', configAbsPath]);
116
+ return retval.then(child => {
117
+ if (child.exitCode === 0) return;
118
+ else process.exit(child.exitCode);
119
+ });
118
120
  }
119
121
 
120
122
  return sendAsyncRes('Initialized successfully.');