ts-pantry 0.11.21 → 0.11.27
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/dist/bin/cli.js +98 -98
- package/dist/installer.d.ts +3 -0
- package/dist/packages/ansiblecom.d.ts +1 -1
- package/dist/packages/anthropic.com/claude-code.d.ts +1 -1
- package/dist/packages/apps/codexopenaicom.d.ts +1 -1
- package/dist/packages/apps/cursorcom.d.ts +1 -1
- package/dist/packages/apps/diabrowsercom.d.ts +1 -1
- package/dist/packages/apps/discordcom.d.ts +1 -1
- package/dist/packages/apps/lmstudioai.d.ts +1 -1
- package/dist/packages/apps/obsidianmd.d.ts +1 -1
- package/dist/packages/apps/slackcom.d.ts +1 -1
- package/dist/packages/apps/statsapp.d.ts +1 -1
- package/dist/packages/apps/whatsappcom.d.ts +1 -1
- package/dist/packages/apps/zeddev.d.ts +1 -1
- package/dist/packages/argoproj.github.io/cd.d.ts +1 -1
- package/dist/packages/argoproj.github.io/workflows.d.ts +1 -1
- package/dist/packages/arkadedev.d.ts +1 -1
- package/dist/packages/aux4io.d.ts +1 -1
- package/dist/packages/buildpacksio.d.ts +1 -1
- package/dist/packages/bytebasecom.d.ts +1 -1
- package/dist/packages/casdoororg.d.ts +1 -1
- package/dist/packages/circlecicom.d.ts +1 -1
- package/dist/packages/cnqueryio.d.ts +1 -1
- package/dist/packages/coder.com/code-server.d.ts +1 -1
- package/dist/packages/codercom.d.ts +1 -1
- package/dist/packages/crates.io/qsv.d.ts +1 -1
- package/dist/packages/dblabdanvergaracom.d.ts +1 -1
- package/dist/packages/depotdev.d.ts +1 -1
- package/dist/packages/diggerdev.d.ts +1 -1
- package/dist/packages/dotnetmicrosoftcom.d.ts +1 -1
- package/dist/packages/dozzledev.d.ts +1 -1
- package/dist/packages/eksctlio.d.ts +1 -1
- package/dist/packages/encoredev.d.ts +1 -1
- package/dist/packages/fastlanetools.d.ts +1 -1
- package/dist/packages/flyio.d.ts +1 -1
- package/dist/packages/getzolaorg.d.ts +1 -1
- package/dist/packages/github.com/chainguard-dev/apko.d.ts +1 -1
- package/dist/packages/github.com/ggerganov/llama.cpp.d.ts +1 -1
- package/dist/packages/github.com/mail-os/mail.d.ts +1 -1
- package/dist/packages/github.com/router-for-me/CLIProxyAPI.d.ts +1 -1
- package/dist/packages/github.com/tw93/mole.d.ts +1 -1
- package/dist/packages/gohugoio.d.ts +1 -1
- package/dist/packages/harfbuzzorg.d.ts +1 -1
- package/dist/packages/harlequinsh.d.ts +1 -1
- package/dist/packages/hatchpypaio.d.ts +1 -1
- package/dist/packages/helmsh.d.ts +1 -1
- package/dist/packages/htopdev.d.ts +1 -1
- package/dist/packages/julialangorg.d.ts +1 -1
- package/dist/packages/jupyterorg.d.ts +1 -1
- package/dist/packages/k6io.d.ts +1 -1
- package/dist/packages/kubesharkco.d.ts +1 -1
- package/dist/packages/lavinmqcom.d.ts +1 -1
- package/dist/packages/libgeosorg.d.ts +1 -1
- package/dist/packages/libgit2org.d.ts +1 -1
- package/dist/packages/materializecom.d.ts +1 -1
- package/dist/packages/meilisearchcom.d.ts +1 -1
- package/dist/packages/mesonbuildcom.d.ts +1 -1
- package/dist/packages/misejdxdev.d.ts +1 -1
- package/dist/packages/mongodb.com/shell.d.ts +1 -1
- package/dist/packages/moonrepo.dev/moon.d.ts +1 -1
- package/dist/packages/nomadprojectio.d.ts +1 -1
- package/dist/packages/numpyorg.d.ts +1 -1
- package/dist/packages/nushellsh.d.ts +1 -1
- package/dist/packages/odigosio.d.ts +1 -1
- package/dist/packages/ohmyposhdev.d.ts +1 -1
- package/dist/packages/ollamaai.d.ts +1 -1
- package/dist/packages/opencodeai.d.ts +1 -1
- package/dist/packages/openshiftcom.d.ts +1 -1
- package/dist/packages/planetscalecom.d.ts +1 -1
- package/dist/packages/pnpmio.d.ts +1 -1
- package/dist/packages/pocketbaseio.d.ts +1 -1
- package/dist/packages/podmanio.d.ts +1 -1
- package/dist/packages/postgresqlorg.d.ts +1 -1
- package/dist/packages/postgrestorg.d.ts +1 -1
- package/dist/packages/prefixdev.d.ts +1 -1
- package/dist/packages/projenio.d.ts +1 -1
- package/dist/packages/pulumiio.d.ts +1 -1
- package/dist/packages/qpdfsourceforgeio.d.ts +1 -1
- package/dist/packages/railwayapp.d.ts +1 -1
- package/dist/packages/riotermcom.d.ts +1 -1
- package/dist/packages/rsyncsambaorg.d.ts +1 -1
- package/dist/packages/sconsorg.d.ts +1 -1
- package/dist/packages/spacetimedbcom.d.ts +1 -1
- package/dist/packages/steampipeio.d.ts +1 -1
- package/dist/packages/stripecom.d.ts +1 -1
- package/dist/packages/terragruntgruntworkio.d.ts +1 -1
- package/dist/packages/tiltdev.d.ts +1 -1
- package/dist/packages/toxwiki.d.ts +1 -1
- package/dist/packages/wailsio.d.ts +1 -1
- package/dist/packages/werfio.d.ts +1 -1
- package/dist/packages/xplrdev.d.ts +1 -1
- package/dist/packages/ziglangorg.d.ts +1 -1
- package/dist/src/index.js +97 -236
- package/dist/src/testing/index.js +1 -1
- package/dist/testing/index.d.ts +47 -25
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{execSync as H}from"node:child_process";var b=new Set,O=!1;function v(){if(O)return;O=!0;let n=()=>{for(let o of b)try{H(`pantry stop ${o}`,{stdio:"ignore",timeout:1e4})}catch{}b.clear()};process.on("exit",n),process.on("SIGINT",()=>{n(),process.exit(130)}),process.on("SIGTERM",()=>{n(),process.exit(143)})}function R(n,o=!1){let C={encoding:"utf-8",timeout:30000,stdio:o?"pipe":["pipe","pipe","pipe"]};return H(`pantry ${n}`,C)}function P(n){let o=n.match(/Name:\s+(\S+)/)?.[1]??"",C=/Status:\s+running/i.test(n),A=n.match(/Port:\s+(\d+)/),w=n.match(/PID:\s+(\d+)/),N=n.match(/Data Dir:\s+(.+)/);return{name:o,running:C,port:A?Number.parseInt(A[1],10):null,pid:w?Number.parseInt(w[1],10):null,dataDir:N?N[1].trim():null}}class l{config;_startedByUs=!1;constructor(n){this.config={name:n.name,port:n.port??0,readyTimeoutMs:n.readyTimeoutMs??15000,pollIntervalMs:n.pollIntervalMs??200,quiet:n.quiet??!0}}static isAvailable(){try{return H("pantry --version",{stdio:"ignore",timeout:5000}),!0}catch{return!1}}status(){try{let n=R(`inspect ${this.config.name}`,!0);return P(n)}catch{return{name:this.config.name,running:!1,port:null,pid:null,dataDir:null}}}isRunning(){return this.status().running}getPort(){return this.status().port}async start(){if(v(),this.isRunning())return this.status();return R(`start ${this.config.name}`,this.config.quiet),this._startedByUs=!0,b.add(this.config.name),await this.waitReady(),this.status()}async stop(){if(!this._startedByUs)return;try{R(`stop ${this.config.name}`,this.config.quiet)}catch{}b.delete(this.config.name),this._startedByUs=!1}async forceStop(){try{R(`stop ${this.config.name}`,this.config.quiet)}catch{}b.delete(this.config.name),this._startedByUs=!1}async ensureRunning(){if(this.isRunning())return this.status();return this.start()}async waitReady(){let n=Date.now()+this.config.readyTimeoutMs;while(Date.now()<n){if(this.isRunning())return;await new Promise((o)=>setTimeout(o,this.config.pollIntervalMs))}throw Error(`Service '${this.config.name}' did not become ready within ${this.config.readyTimeoutMs}ms`)}}var U=new l({name:"mysql"});async function q(n){let o=await U.ensureRunning();return{port:n?.port??o.port??3306,host:n?.host??"localhost",database:n?.database??"test",username:n?.username??"root"}}async function Q(){await U.stop()}function V(n){let o=null;return{get connection(){if(!o)throw Error("MySQL not started. Ensure beforeAll has run.");return o},beforeAll:async()=>{o=await q(n)},afterAll:async()=>{await Q(),o=null}}}async function X(n,o){let C=await q(o);try{return await n(C)}finally{if(o?.stopAfter!==!1)await Q()}}var Y=new l({name:"postgres"});async function $(n){let o=await Y.ensureRunning();return{port:n?.port??o.port??5432,host:n?.host??"localhost",database:n?.database??"postgres",username:n?.username??process.env.USER??"postgres"}}async function L(){await Y.stop()}function Z(n){let o=null;return{get connection(){if(!o)throw Error("Postgres not started. Ensure beforeAll has run.");return o},beforeAll:async()=>{o=await $(n)},afterAll:async()=>{await L(),o=null}}}async function I(n,o){let C=await $(o);try{return await n(C)}finally{if(o?.stopAfter!==!1)await L()}}var W=new l({name:"redis"});async function M(n){let o=await W.ensureRunning(),C=n?.port??o.port??6379,A=n?.host??"localhost";return{port:C,host:A,url:`redis://${A}:${C}`}}async function y(){await W.stop()}function _(n){let o=null;return{get connection(){if(!o)throw Error("Redis not started. Ensure beforeAll has run.");return o},beforeAll:async()=>{o=await M(n)},afterAll:async()=>{await y(),o=null}}}async function E(n,o){let C=await M(o);try{return await n(C)}finally{if(o?.stopAfter!==!1)await y()}}import{existsSync as J,mkdirSync as F,mkdtempSync as f,rmSync as x,writeFileSync as s}from"node:fs";import{tmpdir as S}from"node:os";import{join as K}from"node:path";var z=new Set,j=!1;function h(){if(j)return;j=!0;let n=()=>{for(let o of z)try{if(J(o))x(o,{recursive:!0,force:!0})}catch{}z.clear()};process.on("exit",n),process.on("SIGINT",()=>{n(),process.exit(130)}),process.on("SIGTERM",()=>{n(),process.exit(143)})}function B(n="pantry-test-"){h();let o=f(K(S(),n));return z.add(o),o}function G(n){z.delete(n);try{if(J(n))x(n,{recursive:!0,force:!0})}catch{}}async function k(n,o){let C=B(n);try{return await o(C)}finally{G(C)}}function m(n,o){let C=B(n);try{return o(C)}finally{G(C)}}function u(n,o,C){let A=K(n,o),w=A.substring(0,A.lastIndexOf("/"));if(w&&!J(w))F(w,{recursive:!0});return s(A,C),A}function T(n,o){let C=K(n,o);return F(C,{recursive:!0}),C}var Rn={createTempDir:B,createTestDir:T,createTestFile:u,PantryService:l,removeTempDir:G,startMysql:q,startPostgres:$,startRedis:M,stopMysql:Q,stopPostgres:L,stopRedis:y,useMysql:V,usePostgres:Z,useRedis:_,withMysql:X,withPostgres:I,withRedis:E,withTempDir:k,withTempDirSync:m};export{m as withTempDirSync,k as withTempDir,E as withRedis,I as withPostgres,X as withMysql,_ as useRedis,Z as usePostgres,V as useMysql,Rn as testingRuntime,y as stopRedis,L as stopPostgres,Q as stopMysql,M as startRedis,$ as startPostgres,q as startMysql,G as removeTempDir,u as createTestFile,T as createTestDir,B as createTempDir,l as PantryService};
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,33 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
import { createTempDir, createTestDir, createTestFile, removeTempDir, withTempDir, withTempDirSync } from './temp';
|
|
2
|
+
import { PantryService } from './service';
|
|
3
|
+
import { startMysql, stopMysql, useMysql, withMysql } from './mysql';
|
|
4
|
+
import { startPostgres, stopPostgres, usePostgres, withPostgres } from './postgres';
|
|
5
|
+
import { startRedis, stopRedis, useRedis, withRedis } from './redis';
|
|
6
|
+
export type { MysqlConfig, MysqlConnection } from './mysql';
|
|
7
|
+
export type { PostgresConfig, PostgresConnection } from './postgres';
|
|
8
|
+
export type { RedisConfig, RedisConnection } from './redis';
|
|
9
|
+
export type { TestServiceConfig, TestServiceStatus } from './service';
|
|
10
|
+
// This aggregate is also useful for dynamically selected test infrastructure.
|
|
11
|
+
// Keeping the concrete implementations in an exported value prevents Bun from
|
|
12
|
+
// dropping them while retaining only the named export aliases for this facade.
|
|
13
|
+
export declare const testingRuntime: TestingRuntime;
|
|
14
|
+
export declare interface TestingRuntime {
|
|
15
|
+
createTempDir: typeof createTempDir
|
|
16
|
+
createTestDir: typeof createTestDir
|
|
17
|
+
createTestFile: typeof createTestFile
|
|
18
|
+
PantryService: typeof PantryService
|
|
19
|
+
removeTempDir: typeof removeTempDir
|
|
20
|
+
startMysql: typeof startMysql
|
|
21
|
+
startPostgres: typeof startPostgres
|
|
22
|
+
startRedis: typeof startRedis
|
|
23
|
+
stopMysql: typeof stopMysql
|
|
24
|
+
stopPostgres: typeof stopPostgres
|
|
25
|
+
stopRedis: typeof stopRedis
|
|
26
|
+
useMysql: typeof useMysql
|
|
27
|
+
usePostgres: typeof usePostgres
|
|
28
|
+
useRedis: typeof useRedis
|
|
29
|
+
withMysql: typeof withMysql
|
|
30
|
+
withPostgres: typeof withPostgres
|
|
31
|
+
withRedis: typeof withRedis
|
|
32
|
+
withTempDir: typeof withTempDir
|
|
33
|
+
withTempDirSync: typeof withTempDirSync
|
|
34
|
+
}
|
|
2
35
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
36
|
+
createTempDir,
|
|
37
|
+
createTestDir,
|
|
38
|
+
createTestFile,
|
|
39
|
+
PantryService,
|
|
40
|
+
removeTempDir,
|
|
41
|
+
startMysql,
|
|
5
42
|
startPostgres,
|
|
6
|
-
stopPostgres,
|
|
7
|
-
type PostgresConfig,
|
|
8
|
-
type PostgresConnection,
|
|
9
|
-
} from './postgres';
|
|
10
|
-
export {
|
|
11
|
-
useRedis,
|
|
12
|
-
withRedis,
|
|
13
43
|
startRedis,
|
|
44
|
+
stopMysql,
|
|
45
|
+
stopPostgres,
|
|
14
46
|
stopRedis,
|
|
15
|
-
type RedisConfig,
|
|
16
|
-
type RedisConnection,
|
|
17
|
-
} from './redis';
|
|
18
|
-
export {
|
|
19
47
|
useMysql,
|
|
48
|
+
usePostgres,
|
|
49
|
+
useRedis,
|
|
20
50
|
withMysql,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type MysqlConfig,
|
|
24
|
-
type MysqlConnection,
|
|
25
|
-
} from './mysql';
|
|
26
|
-
export {
|
|
27
|
-
createTempDir,
|
|
28
|
-
removeTempDir,
|
|
51
|
+
withPostgres,
|
|
52
|
+
withRedis,
|
|
29
53
|
withTempDir,
|
|
30
54
|
withTempDirSync,
|
|
31
|
-
|
|
32
|
-
createTestDir,
|
|
33
|
-
} from './temp';
|
|
55
|
+
};
|
package/package.json
CHANGED