@stacksjs/actions 0.75.580 → 0.75.581

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.
@@ -2,4 +2,4 @@ import{existsSync}from"node:fs";import{cp,mkdir,rm}from"node:fs/promises";import
2
2
  ${offenders.join(`
3
3
  `)}
4
4
 
5
- `+"A consumer importing the published package would hit a ReferenceError. Either import those names explicitly "+`in the source, or set \`runtime: 'stx'\` on the package in config/library.ts to declare that it is only ever `+"consumed from inside an stx app.")}async function writeManifest(pkg,config,version){const manifest=libraryManifest(pkg,config,version,pkg.sources.map((source)=>relative(projectPath(),source)));await Bun.write(resolve(pkg.dir,"package.json"),serializeManifest(withRuntime(manifest,pkg)));await Bun.write(resolve(pkg.dir,"README.md"),await readme(pkg,config))}async function readme(pkg,config){if(!pkg.readme)return generatedReadme(pkg,config);const file=Bun.file(projectPath(pkg.readme));if(!await file.exists())throw new LibraryConfigError(`Package "${pkg.name}" names readme "${pkg.readme}", which does not exist.`);return file.text()}function withRuntime(manifest,pkg){if(pkg.runtime!=="stx")return manifest;return{...manifest,stacks:{...manifest.stacks,runtime:"stx"}}}export async function projectVersion(){const manifest=await Bun.file(projectPath("package.json")).json();return manifest.version??"0.0.0"}
5
+ `+"A consumer importing the published package would hit a ReferenceError. Either import those names explicitly "+`in the source, or set \`runtime: 'stx'\` on the package in config/library.ts to declare that it is only ever `+"consumed from inside an stx app.")}async function writeManifest(pkg,config,version){const manifest=libraryManifest(pkg,config,version,pkg.sources.map((source)=>relative(projectPath(),source)),pkg.kind==="functions"||!existsSync(resolve(pkg.dir,"dist"))?[]:await Array.fromAsync(new Bun.Glob("**/*").scan({cwd:resolve(pkg.dir,"dist"),onlyFiles:true})));await Bun.write(resolve(pkg.dir,"package.json"),serializeManifest(withRuntime(manifest,pkg)));await Bun.write(resolve(pkg.dir,"README.md"),await readme(pkg,config))}async function readme(pkg,config){if(!pkg.readme)return generatedReadme(pkg,config);const file=Bun.file(projectPath(pkg.readme));if(!await file.exists())throw new LibraryConfigError(`Package "${pkg.name}" names readme "${pkg.readme}", which does not exist.`);return file.text()}function withRuntime(manifest,pkg){if(pkg.runtime!=="stx")return manifest;return{...manifest,stacks:{...manifest.stacks,runtime:"stx"}}}export async function projectVersion(){const manifest=await Bun.file(projectPath("package.json")).json();return manifest.version??"0.0.0"}
@@ -13,7 +13,7 @@ export declare function generatedReadme(pkg: ResolvedLibraryPackage, config: Lib
13
13
  * project version by default, so the release bump has to be the one deciding
14
14
  * it, and a package that pinned its own `version` in config keeps that.
15
15
  */
16
- export declare function libraryManifest(pkg: ResolvedLibraryPackage, config: LibraryConfig | undefined, version: string, sourcesRelativeToProject: string[]): LibraryManifest;
16
+ export declare function libraryManifest(pkg: ResolvedLibraryPackage, config: LibraryConfig | undefined, version: string, sourcesRelativeToProject: string[], emittedFiles?: readonly string[]): LibraryManifest;
17
17
  /** Drop `undefined` fields so the written manifest stays diff-clean. */
18
18
  export declare function serializeManifest(manifest: LibraryManifest): string;
19
19
  export declare interface LibraryManifest {
@@ -1,3 +1,3 @@
1
1
  export function generatedReadme(pkg,config){const lines=[`# ${pkg.name}`,"",pkg.description,"","## Install","","```sh",`bun add ${pkg.name}`,"```",""];const license=pkg.license??config?.license;if(config?.repository)lines.push(`Source: https://github.com/${config.repository}`,"");if(license)lines.push(`License: ${license}`,"");return lines.join(`
2
- `)}export function libraryManifest(pkg,config,version,sourcesRelativeToProject){const cfg=config??{};const repository=cfg.repository;const manifest={name:pkg.name,type:"module",version:pkg.version??version,description:pkg.description,author:cfg.author,contributors:cfg.contributors,license:pkg.license??cfg.license,homepage:repository?`https://github.com/${repository}#readme`:undefined,repository:repository?{type:"git",url:`git+https://github.com/${repository}.git`}:undefined,bugs:repository?{url:`https://github.com/${repository}/issues`}:undefined,keywords:pkg.keywords.length?pkg.keywords:undefined,exports:{".":{types:"./dist/index.d.ts",import:pkg.kind==="web-components"?"./dist/bundle.js":"./dist/index.js",default:pkg.kind==="web-components"?"./dist/bundle.js":"./dist/index.js"},"./*":{types:"./dist/*.d.ts",import:"./dist/*.js",default:"./dist/*.js"}},module:pkg.kind==="web-components"?"dist/bundle.js":"dist/index.js",types:"dist/index.d.ts",files:["README.md","dist"],dependencies:Object.keys(pkg.dependencies).length?pkg.dependencies:undefined,peerDependencies:Object.keys(pkg.peerDependencies).length?pkg.peerDependencies:undefined,stacks:{kind:pkg.kind,sources:sourcesRelativeToProject}};if(pkg.private)manifest.private=true;else manifest.publishConfig={access:pkg.access};if(pkg.kind!=="functions"){manifest.exports["./style.css"]="./dist/bundle.css";manifest.exports["./custom-elements.json"]="./dist/custom-elements.json"}const assets=pkg.assets??[];const exports=manifest.exports;for(const{dest}of assets){if(/\.[^/]+$/.test(dest))exports[`./${dest}`]=`./dist/${dest}`;else exports[`./${dest}/*`]=`./dist/${dest}/*`}if(assets.length)manifest.stacks.assets=assets.map((asset)=>asset.dest);return manifest}export function serializeManifest(manifest){return`${JSON.stringify(manifest,(_key,value)=>value===undefined?undefined:value,2)}
2
+ `)}export function libraryManifest(pkg,config,version,sourcesRelativeToProject,emittedFiles=[]){const cfg=config??{};const repository=cfg.repository;const manifest={name:pkg.name,type:"module",version:pkg.version??version,description:pkg.description,author:cfg.author,contributors:cfg.contributors,license:pkg.license??cfg.license,homepage:repository?`https://github.com/${repository}#readme`:undefined,repository:repository?{type:"git",url:`git+https://github.com/${repository}.git`}:undefined,bugs:repository?{url:`https://github.com/${repository}/issues`}:undefined,keywords:pkg.keywords.length?pkg.keywords:undefined,exports:{".":{types:"./dist/index.d.ts",import:pkg.kind==="web-components"?"./dist/bundle.js":"./dist/index.js",default:pkg.kind==="web-components"?"./dist/bundle.js":"./dist/index.js"},"./*":{types:"./dist/*.d.ts",import:"./dist/*.js",default:"./dist/*.js"}},module:pkg.kind==="web-components"?"dist/bundle.js":"dist/index.js",types:"dist/index.d.ts",files:["README.md","dist"],dependencies:Object.keys(pkg.dependencies).length?pkg.dependencies:undefined,peerDependencies:Object.keys(pkg.peerDependencies).length?pkg.peerDependencies:undefined,stacks:{kind:pkg.kind,sources:sourcesRelativeToProject}};if(pkg.private)manifest.private=true;else manifest.publishConfig={access:pkg.access};if(pkg.kind!=="functions"){delete manifest.exports["./*"];const files=new Set(emittedFiles);for(const file of[...files].sort()){if(file.endsWith(".js")&&files.has(`${file.slice(0,-3)}.d.ts`)){const entry={types:`./dist/${file.slice(0,-3)}.d.ts`,import:`./dist/${file}`,default:`./dist/${file}`};manifest.exports[`./${file.slice(0,-3)}`]=entry;manifest.exports[`./${file}`]=entry}else if(file.endsWith(".css"))manifest.exports[`./${file}`]=`./dist/${file}`}if(files.has("bundle.js")&&files.has("index.d.ts")){const entry={types:"./dist/index.d.ts",import:"./dist/bundle.js",default:"./dist/bundle.js"};manifest.exports["./bundle"]=entry;manifest.exports["./bundle.js"]=entry}if(files.has("bundle.css"))manifest.exports["./style.css"]="./dist/bundle.css";if(files.has("custom-elements.json"))manifest.exports["./custom-elements.json"]="./dist/custom-elements.json"}const assets=pkg.assets??[];const exports=manifest.exports;for(const{dest}of assets){if(/\.[^/]+$/.test(dest))exports[`./${dest}`]=`./dist/${dest}`;else exports[`./${dest}/*`]=`./dist/${dest}/*`}if(assets.length)manifest.stacks.assets=assets.map((asset)=>asset.dest);return manifest}export function serializeManifest(manifest){return`${JSON.stringify(manifest,(_key,value)=>value===undefined?undefined:value,2)}
3
3
  `}
@@ -26,7 +26,7 @@ export declare function planLibraryPublish(config?: LibraryConfig): Promise<Libr
26
26
  * Every publisher takes the flags the caller adds: `--access` and `--dry-run`
27
27
  * mean the same thing to all three.
28
28
  */
29
- export declare function publishCommand(registry?: 'pantry' | 'npm', which?: (bin: string) => string | null): string[];
29
+ export declare function publishCommand(registry?: 'pantry' | 'npm', which?: (bin: string) => string | null, tag?: string, publisher?: LibraryPublisher): string[];
30
30
  /**
31
31
  * Publish each built package.
32
32
  *
@@ -35,7 +35,7 @@ export declare function publishCommand(registry?: 'pantry' | 'npm', which?: (bin
35
35
  * time means a failure names the package that failed instead of leaving the
36
36
  * set half-published with no record of where it stopped.
37
37
  */
38
- export declare function publishLibraryPackages(options?: { dryRun?: boolean, config?: LibraryConfig }): Promise<LibraryPublishPlan[]>;
38
+ export declare function publishLibraryPackages(options?: { dryRun?: boolean, tag?: string, publisher?: LibraryPublisher, config?: LibraryConfig }): Promise<LibraryPublishPlan[]>;
39
39
  export declare interface LibraryPublishPlan {
40
40
  name: string
41
41
  version: string
@@ -44,3 +44,4 @@ export declare interface LibraryPublishPlan {
44
44
  registry: 'pantry' | 'npm'
45
45
  tarballFiles: number
46
46
  }
47
+ export type LibraryPublisher = 'pantry' | 'bun' | 'npm';
@@ -1,2 +1,2 @@
1
1
  import{existsSync}from"node:fs";import{relative,resolve}from"node:path";import{log}from"@stacksjs/logging";import{projectPath}from"@stacksjs/path";import{configuredLibrary,LibraryConfigError,resolveLibraryPackages}from"./packages";export async function planLibraryPublish(config){const packages=await resolveLibraryPackages(config??await configuredLibrary());const publishable=packages.filter((pkg)=>!pkg.private);if(!publishable.length)throw new LibraryConfigError("Every configured library package is marked private. Nothing to publish.");const plans=[];const missing=[];for(const pkg of publishable){const manifestPath=resolve(pkg.dir,"package.json");const distDir=resolve(pkg.dir,"dist");if(!existsSync(manifestPath)||!existsSync(distDir)){missing.push(pkg.name);continue}const built=await Array.fromAsync(new Bun.Glob("**/*.{js,css,json,d.ts}").scan({cwd:distDir}));if(!built.length){missing.push(pkg.name);continue}const manifest=await Bun.file(manifestPath).json();plans.push({name:pkg.name,version:manifest.version??"0.0.0",dir:pkg.dir,access:pkg.access,registry:pkg.registry,tarballFiles:built.length})}if(missing.length){throw new LibraryConfigError(`These packages have no build output: ${missing.join(", ")}.
2
- Run \`buddy build:libs\` before publishing.`)}return plans}export function publishCommand(registry="pantry",which=Bun.which){if(which("pantry"))return registry==="npm"?["pantry","publish","--npm"]:["pantry","publish"];if(registry==="pantry")throw new Error("This package publishes to the Pantry registry, which only `pantry publish` reaches, and `pantry` is not on PATH. Install pantry, or set `registry: 'npm'` on the package in config/library.ts.");if(which("bun"))return["bun","publish"];if(which("npm"))return["npm","publish"];throw new Error("None of `pantry`, `bun` or `npm` is on PATH, so there is nothing to publish with.")}export async function publishLibraryPackages(options={}){const plans=await planLibraryPublish(options.config);for(const plan of plans){const args=[...publishCommand(plan.registry),"--access",plan.access];if(options.dryRun)args.push("--dry-run");log.info(`${options.dryRun?"[dry run] ":""}${args.join(" ")} (${plan.name}@${plan.version}, ${relative(projectPath(),plan.dir)})`);const proc=Bun.spawnSync({cmd:args,cwd:plan.dir,stdout:"inherit",stderr:"inherit"});if(proc.exitCode!==0)throw new Error(`Publishing ${plan.name}@${plan.version} failed with exit code ${proc.exitCode}.`)}return plans}
2
+ Run \`buddy build:libs\` before publishing.`)}return plans}export function publishCommand(registry="pantry",which=Bun.which,tag,publisher){if(tag!==undefined&&(!/^[a-z][a-z0-9_-]{0,63}$/.test(tag)||/^v\d/.test(tag)))throw new LibraryConfigError("Use a lower-case distribution tag such as alpha, next or latest, not a version or range.");const tagged=(command)=>tag===undefined?command:[...command,"--tag",tag];if(publisher!==undefined){if(!["pantry","bun","npm"].includes(publisher))throw new LibraryConfigError("Choose publisher pantry, bun or npm.");if(registry==="pantry"&&publisher!=="pantry")throw new LibraryConfigError("Only pantry can publish to the Pantry registry.");if(!which(publisher))throw new LibraryConfigError(`Requested publisher ${publisher} is not available on PATH.`);return tagged(publisher==="pantry"&&registry==="npm"?["pantry","publish","--npm"]:[publisher,"publish"])}if(which("pantry"))return tagged(registry==="npm"?["pantry","publish","--npm"]:["pantry","publish"]);if(registry==="pantry")throw new Error("This package publishes to the Pantry registry, which only `pantry publish` reaches, and `pantry` is not on PATH. Install pantry, or set `registry: 'npm'` on the package in config/library.ts.");if(which("bun"))return tagged(["bun","publish"]);if(which("npm"))return tagged(["npm","publish"]);throw new Error("None of `pantry`, `bun` or `npm` is on PATH, so there is nothing to publish with.")}export async function publishLibraryPackages(options={}){if(options.tag!==undefined||options.publisher!==undefined)publishCommand("npm",(bin)=>bin,options.tag,options.publisher);const plans=await planLibraryPublish(options.config);for(const plan of plans){const args=[...publishCommand(plan.registry,Bun.which,options.tag,options.publisher),"--access",plan.access];if(options.dryRun)args.push("--dry-run");log.info(`${options.dryRun?"[dry run] ":""}${args.join(" ")} (${plan.name}@${plan.version}, ${relative(projectPath(),plan.dir)})`);const proc=Bun.spawnSync({cmd:args,cwd:plan.dir,stdout:"inherit",stderr:"inherit"});if(proc.exitCode!==0)throw new Error(`Publishing ${plan.name}@${plan.version} failed with exit code ${proc.exitCode}.`)}return plans}
@@ -1 +1 @@
1
- import{parseOptions}from"@stacksjs/cli";import{log}from"@stacksjs/logging";import{publishLibraryPackages}from"./library/publish";const options=parseOptions();const dryRun=options?.dryRun===true||String(options?.dryRun)==="true";const plans=await publishLibraryPackages({dryRun});log.success(dryRun?`Dry run complete. ${plans.length} package(s) would publish: ${plans.map((plan)=>`${plan.name}@${plan.version}`).join(", ")}`:`Published ${plans.map((plan)=>`${plan.name}@${plan.version}`).join(", ")}`);
1
+ import{parseOptions}from"@stacksjs/cli";import{log}from"@stacksjs/logging";import{publishLibraryPackages}from"./library/publish";const options=parseOptions();const dryRun=options?.dryRun===true||String(options?.dryRun)==="true";const plans=await publishLibraryPackages({dryRun,tag:options?.tag,publisher:options?.publisher});log.success(dryRun?`Dry run complete. ${plans.length} package(s) would publish: ${plans.map((plan)=>`${plan.name}@${plan.version}`).join(", ")}`:`Published ${plans.map((plan)=>`${plan.name}@${plan.version}`).join(", ")}`);
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.580",
5
+ "version": "0.75.581",
6
6
  "description": "The Stacks actions.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -66,55 +66,55 @@
66
66
  "prepublishOnly": "bun run build"
67
67
  },
68
68
  "dependencies": {
69
- "@stacksjs/action-runner": "0.75.580",
70
- "@stacksjs/ai": "0.75.580",
71
- "@stacksjs/analytics": "0.75.580",
72
- "@stacksjs/api": "0.75.580",
73
- "@stacksjs/auth": "0.75.580",
74
- "@stacksjs/build": "0.75.580",
69
+ "@stacksjs/action-runner": "0.75.581",
70
+ "@stacksjs/ai": "0.75.581",
71
+ "@stacksjs/analytics": "0.75.581",
72
+ "@stacksjs/api": "0.75.581",
73
+ "@stacksjs/auth": "0.75.581",
74
+ "@stacksjs/build": "0.75.581",
75
75
  "@stacksjs/bumpx": "^0.2.26",
76
76
  "@stacksjs/bunpress": "^0.2.15",
77
- "@stacksjs/cli": "0.75.580",
78
- "@stacksjs/cloud": "0.75.580",
79
- "@stacksjs/cms": "0.75.580",
77
+ "@stacksjs/cli": "0.75.581",
78
+ "@stacksjs/cloud": "0.75.581",
79
+ "@stacksjs/cms": "0.75.581",
80
80
  "@stacksjs/components": "^0.2.872",
81
- "@stacksjs/config": "0.75.580",
82
- "@stacksjs/database": "0.75.580",
83
- "@stacksjs/desktop-build": "0.75.580",
84
- "@stacksjs/dns": "0.75.580",
85
- "@stacksjs/docs": "0.75.580",
86
- "@stacksjs/enums": "0.75.580",
87
- "@stacksjs/env": "0.75.580",
88
- "@stacksjs/error-handling": "0.75.580",
89
- "@stacksjs/github": "0.75.580",
81
+ "@stacksjs/config": "0.75.581",
82
+ "@stacksjs/database": "0.75.581",
83
+ "@stacksjs/desktop-build": "0.75.581",
84
+ "@stacksjs/dns": "0.75.581",
85
+ "@stacksjs/docs": "0.75.581",
86
+ "@stacksjs/enums": "0.75.581",
87
+ "@stacksjs/env": "0.75.581",
88
+ "@stacksjs/error-handling": "0.75.581",
89
+ "@stacksjs/github": "0.75.581",
90
90
  "@stacksjs/gitit": "^0.2.5",
91
- "@stacksjs/i18n": "0.75.580",
92
- "@stacksjs/image": "0.75.580",
93
- "@stacksjs/logging": "0.75.580",
91
+ "@stacksjs/i18n": "0.75.581",
92
+ "@stacksjs/image": "0.75.581",
93
+ "@stacksjs/logging": "0.75.581",
94
94
  "@stacksjs/logsmith": "^0.2.11",
95
- "@stacksjs/mobile": "0.75.580",
96
- "@stacksjs/orm": "0.75.580",
97
- "@stacksjs/path": "0.75.580",
98
- "@stacksjs/payments": "0.75.580",
99
- "@stacksjs/queue": "0.75.580",
100
- "@stacksjs/registry": "0.75.580",
101
- "@stacksjs/router": "0.75.580",
95
+ "@stacksjs/mobile": "0.75.581",
96
+ "@stacksjs/orm": "0.75.581",
97
+ "@stacksjs/path": "0.75.581",
98
+ "@stacksjs/payments": "0.75.581",
99
+ "@stacksjs/queue": "0.75.581",
100
+ "@stacksjs/registry": "0.75.581",
101
+ "@stacksjs/router": "0.75.581",
102
102
  "@stacksjs/rpx": "^0.11.54",
103
- "@stacksjs/scheduler": "0.75.580",
104
- "@stacksjs/search-engine": "0.75.580",
105
- "@stacksjs/security": "0.75.580",
106
- "@stacksjs/server": "0.75.580",
107
- "@stacksjs/sites": "0.75.580",
108
- "@stacksjs/storage": "0.75.580",
109
- "@stacksjs/strings": "0.75.580",
103
+ "@stacksjs/scheduler": "0.75.581",
104
+ "@stacksjs/search-engine": "0.75.581",
105
+ "@stacksjs/security": "0.75.581",
106
+ "@stacksjs/server": "0.75.581",
107
+ "@stacksjs/sites": "0.75.581",
108
+ "@stacksjs/storage": "0.75.581",
109
+ "@stacksjs/strings": "0.75.581",
110
110
  "@stacksjs/stx": "^0.2.872",
111
111
  "@stacksjs/tlsx": "^0.13.19",
112
112
  "@stacksjs/ts-cloud": "^0.16.125",
113
113
  "@stacksjs/ts-md": "^0.1.1",
114
- "@stacksjs/tunnel": "0.75.580",
115
- "@stacksjs/types": "0.75.580",
116
- "@stacksjs/utils": "0.75.580",
117
- "@stacksjs/whois": "0.75.580",
114
+ "@stacksjs/tunnel": "0.75.581",
115
+ "@stacksjs/types": "0.75.581",
116
+ "@stacksjs/utils": "0.75.581",
117
+ "@stacksjs/whois": "0.75.581",
118
118
  "bun-plugin-stx": "^0.2.872",
119
119
  "pickier": "^0.1.92"
120
120
  },
@@ -127,7 +127,7 @@
127
127
  }
128
128
  },
129
129
  "devDependencies": {
130
- "@stacksjs/validation": "0.75.580",
130
+ "@stacksjs/validation": "0.75.581",
131
131
  "better-dx": "^0.2.39"
132
132
  }
133
133
  }