@stacksjs/actions 0.75.357 → 0.75.361

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/dist/test/runner.js +1 -1
  2. package/package.json +40 -40
@@ -1 +1 @@
1
- import process from"node:process";import{existsSync,realpathSync,statSync}from"node:fs";import{join,relative,resolve}from"node:path";import{log}from"@stacksjs/cli";import{projectPath}from"@stacksjs/path";const testFilePattern="**/*.{test,spec}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}";export function resolveTestSuiteFilters(project,suites){const visitedDirectories=new Set;return suites.flatMap((suite)=>{const suiteDirectory=join(project,"tests",suite);if(!existsSync(suiteDirectory))return[];const canonicalDirectory=realpathSync(suiteDirectory);if(visitedDirectories.has(canonicalDirectory))return[];visitedDirectories.add(canonicalDirectory);return[...new Bun.Glob(testFilePattern).scanSync({cwd:suiteDirectory,onlyFiles:!0})].map((file)=>suite?`./tests/${suite}/${file}`:`./tests/${file}`)})}export function namedTestPaths(){const raw=process.env.STACKS_TEST_PATHS;if(!raw)return[];try{const parsed=JSON.parse(raw);return Array.isArray(parsed)?parsed.filter((path)=>typeof path==="string"):[]}catch{return[]}}export function resolveNamedTestFiles(project,paths){const found=new Set;for(const named of paths){const absolute=resolve(project,named),rel=relative(project,absolute).split("\\").join("/");if(rel===".."||rel.startsWith("../"))throw Error(`Cannot run ${named}: it is outside the project at ${project}`);if(!existsSync(absolute))throw Error(`Cannot run ${named}: no such file or directory`);if(statSync(absolute).isDirectory()){const under=[...new Bun.Glob(testFilePattern).scanSync({cwd:absolute,onlyFiles:!0})].map((file)=>`./${rel?`${rel}/`:""}${file.split("\\").join("/")}`);if(under.length===0)throw Error(`Cannot run ${named}: it holds no test files`);for(const file of under)found.add(file);continue}if(!new Bun.Glob(testFilePattern).match(rel))throw Error(`Cannot run ${named}: a test file is named *.test.ts or *.spec.ts (or .js, .tsx, .mts, ...)`);found.add(`./${rel}`)}return[...found].sort()}export function withinSuite(files,suite,paths){const prefix=`./tests/${suite}/`,inSuite=files.filter((file)=>file.startsWith(prefix));if(inSuite.length===0)throw Error(`No ${suite} tests under ${paths.join(" ")}. Run \`buddy test ${paths.join(" ")}\` for the tests that are there.`);return inSuite}export async function runTestSuites(suites,timeout,paths){const project=projectPath();let filters;if(paths?.length)try{const named=resolveNamedTestFiles(project,paths),suite=suites.find(Boolean);filters=suite?withinSuite(named,suite,paths):named}catch(error){await log.error(error instanceof Error?error.message:String(error));process.exit(1)}else filters=resolveTestSuiteFilters(project,suites);if(filters.length===0){log.info("No matching tests found.");return}const args=["bun","test"];if(timeout)args.push("--timeout",String(timeout));args.push(...filters);const exitCode=await Bun.spawn(args,{cwd:project,stdio:["inherit","inherit","inherit"]}).exited;if(exitCode!==0){await log.error("Tests failed");process.exit(exitCode??1)}}
1
+ import process from"node:process";import{existsSync,realpathSync,statSync}from"node:fs";import{join,relative,resolve}from"node:path";import{log}from"@stacksjs/cli";import{projectPath}from"@stacksjs/path";const testFilePattern="**/*.{test,spec}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}";export function resolveTestSuiteFilters(project,suites){const visitedDirectories=new Set;return suites.flatMap((suite)=>{const suiteDirectory=join(project,"tests",suite);if(!existsSync(suiteDirectory))return[];const canonicalDirectory=realpathSync(suiteDirectory);if(visitedDirectories.has(canonicalDirectory))return[];visitedDirectories.add(canonicalDirectory);return[...new Bun.Glob(testFilePattern).scanSync({cwd:suiteDirectory,onlyFiles:!0})].map((file)=>suite?`./tests/${suite}/${file}`:`./tests/${file}`)})}export function namedTestPaths(){const raw=process.env.STACKS_TEST_PATHS;if(!raw)return[];try{const parsed=JSON.parse(raw);return Array.isArray(parsed)?parsed.filter((path)=>typeof path==="string"):[]}catch{return[]}}export function resolveNamedTestFiles(project,paths){const found=new Set;for(const named of paths){const absolute=resolve(project,named),rel=relative(project,absolute).split("\\").join("/");if(rel===".."||rel.startsWith("../"))throw Error(`Cannot run ${named}: it is outside the project at ${project}`);if(!existsSync(absolute))throw Error(`Cannot run ${named}: no such file or directory`);if(statSync(absolute).isDirectory()){const under=[...new Bun.Glob(testFilePattern).scanSync({cwd:absolute,onlyFiles:!0})].map((file)=>`./${rel?`${rel}/`:""}${file.split("\\").join("/")}`);if(under.length===0)throw Error(`Cannot run ${named}: it holds no test files`);for(const file of under)found.add(file);continue}if(!new Bun.Glob(testFilePattern).match(rel))throw Error(`Cannot run ${named}: a test file is named *.test.ts or *.spec.ts (or .js, .tsx, .mts, ...)`);found.add(`./${rel}`)}return[...found].sort()}export function withinSuite(files,suite,paths){const prefix=`./tests/${suite}/`,inSuite=files.filter((file)=>file.startsWith(prefix));if(inSuite.length===0)throw Error(`No ${suite} tests under ${paths.join(" ")}. Run \`buddy test ${paths.join(" ")}\` for the tests that are there.`);return inSuite}export async function runTestSuites(suites,timeout,paths){const project=projectPath();let filters;if(paths?.length)try{const named=resolveNamedTestFiles(project,paths),suite=suites.find(Boolean);filters=suite?withinSuite(named,suite,paths):named}catch(error){await log.error(error instanceof Error?error.message:String(error));process.exit(1)}else filters=resolveTestSuiteFilters(project,suites);if(filters.length===0){log.info("No matching tests found.");return}const args=["bun","test","--isolate"];if(timeout)args.push("--timeout",String(timeout));args.push(...filters);const exitCode=await Bun.spawn(args,{cwd:project,stdio:["inherit","inherit","inherit"]}).exited;if(exitCode!==0){await log.error("Tests failed");process.exit(exitCode??1)}}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/actions",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.357",
5
+ "version": "0.75.361",
6
6
  "description": "The Stacks actions.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -66,54 +66,54 @@
66
66
  "prepublishOnly": "bun run build"
67
67
  },
68
68
  "dependencies": {
69
- "@stacksjs/action-runner": "0.75.357",
70
- "@stacksjs/ai": "0.75.357",
71
- "@stacksjs/analytics": "0.75.357",
72
- "@stacksjs/api": "0.75.357",
73
- "@stacksjs/auth": "0.75.357",
74
- "@stacksjs/build": "0.75.357",
69
+ "@stacksjs/action-runner": "0.75.361",
70
+ "@stacksjs/ai": "0.75.361",
71
+ "@stacksjs/analytics": "0.75.361",
72
+ "@stacksjs/api": "0.75.361",
73
+ "@stacksjs/auth": "0.75.361",
74
+ "@stacksjs/build": "0.75.361",
75
75
  "@stacksjs/bumpx": "^0.2.26",
76
76
  "@stacksjs/bunpress": "^0.2.15",
77
- "@stacksjs/cli": "0.75.357",
78
- "@stacksjs/cloud": "0.75.357",
79
- "@stacksjs/cms": "0.75.357",
77
+ "@stacksjs/cli": "0.75.361",
78
+ "@stacksjs/cloud": "0.75.361",
79
+ "@stacksjs/cms": "0.75.361",
80
80
  "@stacksjs/components": "0.2.736",
81
- "@stacksjs/config": "0.75.357",
82
- "@stacksjs/database": "0.75.357",
83
- "@stacksjs/desktop-build": "0.75.357",
84
- "@stacksjs/dns": "0.75.357",
85
- "@stacksjs/enums": "0.75.357",
86
- "@stacksjs/env": "0.75.357",
87
- "@stacksjs/error-handling": "0.75.357",
88
- "@stacksjs/github": "0.75.357",
81
+ "@stacksjs/config": "0.75.361",
82
+ "@stacksjs/database": "0.75.361",
83
+ "@stacksjs/desktop-build": "0.75.361",
84
+ "@stacksjs/dns": "0.75.361",
85
+ "@stacksjs/enums": "0.75.361",
86
+ "@stacksjs/env": "0.75.361",
87
+ "@stacksjs/error-handling": "0.75.361",
88
+ "@stacksjs/github": "0.75.361",
89
89
  "@stacksjs/gitit": "^0.2.5",
90
- "@stacksjs/i18n": "0.75.357",
91
- "@stacksjs/image": "0.75.357",
92
- "@stacksjs/logging": "0.75.357",
90
+ "@stacksjs/i18n": "0.75.361",
91
+ "@stacksjs/image": "0.75.361",
92
+ "@stacksjs/logging": "0.75.361",
93
93
  "@stacksjs/logsmith": "^0.2.11",
94
- "@stacksjs/mobile": "0.75.357",
95
- "@stacksjs/orm": "0.75.357",
96
- "@stacksjs/path": "0.75.357",
97
- "@stacksjs/payments": "0.75.357",
98
- "@stacksjs/queue": "0.75.357",
99
- "@stacksjs/registry": "0.75.357",
100
- "@stacksjs/router": "0.75.357",
94
+ "@stacksjs/mobile": "0.75.361",
95
+ "@stacksjs/orm": "0.75.361",
96
+ "@stacksjs/path": "0.75.361",
97
+ "@stacksjs/payments": "0.75.361",
98
+ "@stacksjs/queue": "0.75.361",
99
+ "@stacksjs/registry": "0.75.361",
100
+ "@stacksjs/router": "0.75.361",
101
101
  "@stacksjs/rpx": "^0.11.54",
102
- "@stacksjs/scheduler": "0.75.357",
103
- "@stacksjs/search-engine": "0.75.357",
104
- "@stacksjs/security": "0.75.357",
105
- "@stacksjs/server": "0.75.357",
106
- "@stacksjs/sites": "0.75.357",
107
- "@stacksjs/storage": "0.75.357",
108
- "@stacksjs/strings": "0.75.357",
102
+ "@stacksjs/scheduler": "0.75.361",
103
+ "@stacksjs/search-engine": "0.75.361",
104
+ "@stacksjs/security": "0.75.361",
105
+ "@stacksjs/server": "0.75.361",
106
+ "@stacksjs/sites": "0.75.361",
107
+ "@stacksjs/storage": "0.75.361",
108
+ "@stacksjs/strings": "0.75.361",
109
109
  "@stacksjs/stx": "0.2.736",
110
110
  "@stacksjs/tlsx": "^0.13.19",
111
111
  "@stacksjs/ts-cloud": "^0.16.69",
112
112
  "@stacksjs/ts-md": "^0.1.1",
113
- "@stacksjs/tunnel": "0.75.357",
114
- "@stacksjs/types": "0.75.357",
115
- "@stacksjs/utils": "0.75.357",
116
- "@stacksjs/whois": "0.75.357",
113
+ "@stacksjs/tunnel": "0.75.361",
114
+ "@stacksjs/types": "0.75.361",
115
+ "@stacksjs/utils": "0.75.361",
116
+ "@stacksjs/whois": "0.75.361",
117
117
  "bun-plugin-stx": "0.2.736"
118
118
  },
119
119
  "peerDependencies": {
@@ -129,7 +129,7 @@
129
129
  }
130
130
  },
131
131
  "devDependencies": {
132
- "@stacksjs/validation": "0.75.357",
132
+ "@stacksjs/validation": "0.75.361",
133
133
  "better-dx": "^0.2.24"
134
134
  }
135
135
  }