@stacksjs/actions 0.75.403 → 0.75.405

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.
@@ -1,4 +1,4 @@
1
- import{mkdir,rm}from"node:fs/promises";import{dirname,relative,resolve}from"node:path";import{transpilePackage,validateDeclarations,validateRuntimeExports}from"@stacksjs/build";import{awaitConfig,library}from"@stacksjs/config";import{log}from"@stacksjs/logging";import{projectPath}from"@stacksjs/path";import{buildComponentLibrary}from"@stacksjs/stx";import{functionEntryData}from"./entries";import{ambientGlobalsUsed,stxAmbientGlobals}from"./globals";import{libraryManifest,serializeManifest}from"./manifest";import{LibraryConfigError,resolveLibraryPackages}from"./packages";export async function buildLibraryPackages(options={}){if(!options.config)await awaitConfig();const config=options.config??library,kinds=options.kinds,compile=options.compile??!0,all=await resolveLibraryPackages(config,{onUnmatched:options.allowEmpty?"skip":"error"}),packages=kinds?all.filter((pkg)=>kinds.includes(pkg.kind)):all;if(!packages.length){if(options.allowEmpty){log.info("No library packages are configured. Nothing to build.");return[]}throw new LibraryConfigError(kinds?`No ${kinds.join("/")} packages are configured. Add one to \`packages\` in config/library.ts.`:"No library packages are configured. Add one to `packages` in config/library.ts.")}const version=await projectVersion(),reports=[];for(const pkg of packages){const verb=compile?"Building":"Generating";log.info(`${verb} ${pkg.name} (${pkg.kind}, ${pkg.sources.length} source${pkg.sources.length===1?"":"s"})...`);if(compile)await rm(resolve(pkg.dir,"dist"),{recursive:!0,force:!0});await mkdir(pkg.dir,{recursive:!0});if(pkg.kind==="functions")await buildFunctionPackage(pkg,config,version,compile);else await buildComponentPackage(pkg,config,version,compile);reports.push({name:pkg.name,kind:pkg.kind,dir:pkg.dir,sources:pkg.sources.length});if(compile)log.success(`Built ${pkg.name} \u2192 ${relative(projectPath(),pkg.dir)}/dist`)}return reports}export async function generateLibraryPackages(options={}){return buildLibraryPackages({...options,compile:!1})}async function buildFunctionPackage(pkg,config,version,compile){await assertPublishable(pkg);const srcDir=resolve(pkg.dir,"src");await rm(srcDir,{recursive:!0,force:!0});const staged=[];for(const source of pkg.sources){const destination=resolve(srcDir,relative(pkg.sourceDir,source));await mkdir(dirname(destination),{recursive:!0});await Bun.write(destination,await Bun.file(source).text());staged.push(destination)}const entry=resolve(srcDir,"index.ts");if(staged.includes(entry))throw new LibraryConfigError(`Package "${pkg.name}" claims resources/functions/index.ts, which collides with the generated barrel. Rename it or exclude it.`);await Bun.write(entry,functionEntryData(pkg,staged));await writeManifest(pkg,config,version);if(!compile)return;await transpilePackage({dir:pkg.dir,pkgName:pkg.name,external:["@stacksjs/*","bun",...Object.keys(pkg.dependencies),...Object.keys(pkg.peerDependencies)]});await validateDeclarations(pkg.dir);await validateRuntimeExports(pkg.dir)}async function buildComponentPackage(pkg,config,version,compile){if(!compile){await writeManifest(pkg,config,version);return}const result=await buildComponentLibrary({inputDir:pkg.sourceDir,outputDir:resolve(pkg.dir,"dist"),prefix:pkg.prefix,components:pkg.sources.map((source)=>{const file=relative(pkg.sourceDir,source),stem=file.replace(/\.stx$/,"").split("/").at(-1);return pkg.names[stem]?{file,name:pkg.names[stem]}:{file}}),progressive:!0,manifest:!0,declarations:!0,css:!0,bundle:!0,minify:!0,sourcemap:pkg.sourcemap?"external":!1});log.debug(`${pkg.name}: compiled ${result.components.length} components (${result.totalBytes} bytes)`);await writeManifest(pkg,config,version);await validateDeclarations(pkg.dir);await validateRuntimeExports(pkg.dir)}async function assertPublishable(pkg){if(pkg.runtime==="stx")return;const globals=await stxAmbientGlobals();if(!globals.size)return;const offenders=[];for(const source of pkg.sources){const used=ambientGlobalsUsed(await Bun.file(source).text(),globals);if(used.length)offenders.push(` ${relative(projectPath(),source)} \u2192 ${used.join(", ")}`)}if(!offenders.length)return;throw new LibraryConfigError(`Package "${pkg.name}" uses stx's ambient globals, which no module exports:
1
+ import{mkdir,rm}from"node:fs/promises";import{dirname,relative,resolve}from"node:path";import{transpilePackage,validateDeclarations,validateRuntimeExports}from"@stacksjs/build";import{log}from"@stacksjs/logging";import{projectPath}from"@stacksjs/path";import{buildComponentLibrary}from"@stacksjs/stx";import{functionEntryData}from"./entries";import{ambientGlobalsUsed,stxAmbientGlobals}from"./globals";import{libraryManifest,serializeManifest}from"./manifest";import{configuredLibrary,LibraryConfigError,resolveLibraryPackages}from"./packages";export async function buildLibraryPackages(options={}){const config=options.config??await configuredLibrary(),kinds=options.kinds,compile=options.compile??!0,all=await resolveLibraryPackages(config,{onUnmatched:options.allowEmpty?"skip":"error"}),packages=kinds?all.filter((pkg)=>kinds.includes(pkg.kind)):all;if(!packages.length){if(options.allowEmpty){log.info("No library packages are configured. Nothing to build.");return[]}throw new LibraryConfigError(kinds?`No ${kinds.join("/")} packages are configured. Add one to \`packages\` in config/library.ts.`:"No library packages are configured. Add one to `packages` in config/library.ts.")}const version=await projectVersion(),reports=[];for(const pkg of packages){const verb=compile?"Building":"Generating";log.info(`${verb} ${pkg.name} (${pkg.kind}, ${pkg.sources.length} source${pkg.sources.length===1?"":"s"})...`);if(compile)await rm(resolve(pkg.dir,"dist"),{recursive:!0,force:!0});await mkdir(pkg.dir,{recursive:!0});if(pkg.kind==="functions")await buildFunctionPackage(pkg,config,version,compile);else await buildComponentPackage(pkg,config,version,compile);reports.push({name:pkg.name,kind:pkg.kind,dir:pkg.dir,sources:pkg.sources.length});if(compile)log.success(`Built ${pkg.name} \u2192 ${relative(projectPath(),pkg.dir)}/dist`)}return reports}export async function generateLibraryPackages(options={}){return buildLibraryPackages({...options,compile:!1})}async function buildFunctionPackage(pkg,config,version,compile){await assertPublishable(pkg);const srcDir=resolve(pkg.dir,"src");await rm(srcDir,{recursive:!0,force:!0});const staged=[];for(const source of pkg.sources){const destination=resolve(srcDir,relative(pkg.sourceDir,source));await mkdir(dirname(destination),{recursive:!0});await Bun.write(destination,await Bun.file(source).text());staged.push(destination)}const entry=resolve(srcDir,"index.ts");if(staged.includes(entry))throw new LibraryConfigError(`Package "${pkg.name}" claims resources/functions/index.ts, which collides with the generated barrel. Rename it or exclude it.`);await Bun.write(entry,functionEntryData(pkg,staged));await writeManifest(pkg,config,version);if(!compile)return;await transpilePackage({dir:pkg.dir,pkgName:pkg.name,external:["@stacksjs/*","bun",...Object.keys(pkg.dependencies),...Object.keys(pkg.peerDependencies)]});await validateDeclarations(pkg.dir);await validateRuntimeExports(pkg.dir)}async function buildComponentPackage(pkg,config,version,compile){if(!compile){await writeManifest(pkg,config,version);return}const result=await buildComponentLibrary({inputDir:pkg.sourceDir,outputDir:resolve(pkg.dir,"dist"),prefix:pkg.prefix,components:pkg.sources.map((source)=>{const file=relative(pkg.sourceDir,source),stem=file.replace(/\.stx$/,"").split("/").at(-1);return pkg.names[stem]?{file,name:pkg.names[stem]}:{file}}),progressive:!0,manifest:!0,declarations:!0,css:!0,bundle:!0,minify:!0,sourcemap:pkg.sourcemap?"external":!1});log.debug(`${pkg.name}: compiled ${result.components.length} components (${result.totalBytes} bytes)`);await writeManifest(pkg,config,version);await validateDeclarations(pkg.dir);await validateRuntimeExports(pkg.dir)}async function assertPublishable(pkg){if(pkg.runtime==="stx")return;const globals=await stxAmbientGlobals();if(!globals.size)return;const offenders=[];for(const source of pkg.sources){const used=ambientGlobalsUsed(await Bun.file(source).text(),globals);if(used.length)offenders.push(` ${relative(projectPath(),source)} \u2192 ${used.join(", ")}`)}if(!offenders.length)return;throw new LibraryConfigError(`Package "${pkg.name}" uses stx's ambient globals, which no module exports:
2
2
  ${offenders.join(`
3
3
  `)}
4
4
 
@@ -1,4 +1,10 @@
1
1
  import type { LibraryConfig, LibraryPackageKind } from '@stacksjs/types';
2
+ /**
3
+ * The app's `config/library.ts`, once it has loaded. Read `library` from
4
+ * `@stacksjs/config` straight away and it is still the framework's sample
5
+ * config, which is how `libs:publish` once refused an app's own package.
6
+ */
7
+ export declare function configuredLibrary(): Promise<LibraryConfig | undefined>;
2
8
  /** Where a package of this kind reads its sources from. */
3
9
  export declare function libraryPackageSourceDir(kind: LibraryPackageKind): string;
4
10
  /** `@acme/ui` -> `ui`. Used for the default slug, prefix and tag namespace. */
@@ -55,6 +61,7 @@ export declare interface LibraryPackageDefinition {
55
61
  version?: string
56
62
  private: boolean
57
63
  access: 'public' | 'restricted'
64
+ registry: 'pantry' | 'npm'
58
65
  runtime: 'standalone' | 'stx'
59
66
  sourcemap: boolean
60
67
  include: string[]
@@ -1 +1 @@
1
- import{existsSync}from"node:fs";import{relative,resolve}from"node:path";import process from"node:process";import{componentsPath,functionsPath,libraryPackagePath}from"@stacksjs/path";export class LibraryConfigError extends Error{name="LibraryConfigError"}const DEFAULT_FUNCTION_INCLUDE=["**/*.ts"],DEFAULT_FUNCTION_EXCLUDE=["**/*.test.ts","**/*.spec.ts","**/*.d.ts","**/_*.ts"],DEFAULT_COMPONENT_INCLUDE=["**/*.stx"],DEFAULT_COMPONENT_EXCLUDE=[];export function libraryPackageSourceDir(kind){return kind==="functions"?functionsPath():componentsPath()}export function unscopedName(name){return name.split("/").at(-1)??name}function includeFromFilesEntry(entry){const[file,alias]=Array.isArray(entry)?entry:[entry,void 0],stem=file.replace(/\.ts$/,""),include=stem==="*"?"*.ts":`${stem}.ts`;return alias?{include,alias:[stem,alias]}:{include}}function toDefinition(option,fallback){const name=option.name?.trim();if(!name)throw new LibraryConfigError(`library.packages[${fallback.index}] has no name. Every package needs the name it is published under.`);if(name.startsWith(".")||name.includes("\\")||name.split("/").length>2)throw new LibraryConfigError(`library.packages[${fallback.index}] has an invalid npm name: "${name}".`);const kind=option.kind??"functions";if(kind!=="functions"&&kind!=="components"&&kind!=="web-components")throw new LibraryConfigError(`Package "${name}" has an unknown kind "${kind}". Expected 'functions', 'components' or 'web-components'.`);const slug=(option.dir??unscopedName(name)).replace(/^@/,"");if(!/^[\w.-]+$/.test(slug))throw new LibraryConfigError(`Package "${name}" resolves to the directory "${slug}", which is not a single safe path segment. Set \`dir\` explicitly.`);const aliases={},includeFromFiles=[];for(const entry of option.files??[]){const{include,alias}=includeFromFilesEntry(entry);includeFromFiles.push(include);if(alias)aliases[alias[0]]=alias[1]}const names={};for(const tag of option.tags??[])if(Array.isArray(tag.name))names[tag.name[0]]=tag.name[1];const defaultInclude=kind==="functions"?DEFAULT_FUNCTION_INCLUDE:DEFAULT_COMPONENT_INCLUDE,defaultExclude=kind==="functions"?DEFAULT_FUNCTION_EXCLUDE:DEFAULT_COMPONENT_EXCLUDE,includeFromTags=option.tags?.length&&!option.include?.length?option.tags.map((tag)=>`${Array.isArray(tag.name)?tag.name[0]:tag.name}.stx`):[],include=option.include?.length?option.include:includeFromFiles.length?includeFromFiles:includeFromTags.length?includeFromTags:defaultInclude;return{name,kind,slug,description:option.description??`The ${name} library.`,keywords:option.keywords??[],license:option.license??fallback.license,version:option.version,private:option.private??!1,access:option.access??"public",runtime:option.runtime??"standalone",sourcemap:option.shouldGenerateSourcemap??!1,include,exclude:option.exclude??defaultExclude,prefix:option.prefix??unscopedName(name).replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase(),dependencies:option.dependencies??{},peerDependencies:option.peerDependencies??{},aliases,names}}export function normalizeLibraryPackages(config){const cfg=config??{},options=[];if(cfg.packages?.length)options.push(...cfg.packages);else{if(cfg.functions?.name)options.push({...cfg.functions,kind:"functions"});if(cfg.webComponents?.name)options.push({...cfg.webComponents,kind:"web-components"})}const definitions=options.map((option,index)=>toDefinition(option,{license:cfg.license,index})),byName=new Map,bySlug=new Map;for(const definition of definitions){if(byName.has(definition.name))throw new LibraryConfigError(`Two packages are both named "${definition.name}". npm names must be unique.`);byName.set(definition.name,1);const owner=bySlug.get(definition.slug);if(owner)throw new LibraryConfigError(`"${owner}" and "${definition.name}" both build in storage/framework/libs/packages/${definition.slug}. Give one of them a \`dir\`.`);bySlug.set(definition.slug,definition.name)}return definitions}export async function resolveLibraryPackages(config,options={}){const definitions=normalizeLibraryPackages(config),resolved=[];for(const definition of definitions){const sourceDir=libraryPackageSourceDir(definition.kind),sources=await matchSources(sourceDir,definition.include,definition.exclude);if(!sources.length){if(options.onUnmatched==="skip")continue;throw new LibraryConfigError(`Package "${definition.name}" matched no files in ${relative(process.cwd(),sourceDir)} (include: ${definition.include.join(", ")}${definition.exclude.length?`; exclude: ${definition.exclude.join(", ")}`:""}).`)}resolved.push({...definition,sourceDir,sources,dir:libraryPackagePath(definition.slug),entry:libraryPackagePath(definition.slug,"src/index.ts")})}return resolved}export async function matchSources(sourceDir,include,exclude){if(!existsSync(sourceDir))return[];const expand=async(patterns)=>{const files=new Set;for(const pattern of patterns)for await(const file of new Bun.Glob(pattern).scan({cwd:sourceDir,absolute:!0,onlyFiles:!0}))files.add(resolve(file));return files},included=await expand(include),excluded=exclude.length?await expand(exclude):new Set;return[...included].filter((file)=>!excluded.has(file)).sort()}export function entrySpecifier(entry,source){const path=relative(resolve(entry,".."),source).replace(/\.ts$/,"");return path.startsWith(".")?path:`./${path}`}
1
+ import{existsSync}from"node:fs";import{relative,resolve}from"node:path";import process from"node:process";import{awaitConfig,library}from"@stacksjs/config";import{componentsPath,functionsPath,libraryPackagePath}from"@stacksjs/path";export async function configuredLibrary(){await awaitConfig();return library}export class LibraryConfigError extends Error{name="LibraryConfigError"}const DEFAULT_FUNCTION_INCLUDE=["**/*.ts"],DEFAULT_FUNCTION_EXCLUDE=["**/*.test.ts","**/*.spec.ts","**/*.d.ts","**/_*.ts"],DEFAULT_COMPONENT_INCLUDE=["**/*.stx"],DEFAULT_COMPONENT_EXCLUDE=[];export function libraryPackageSourceDir(kind){return kind==="functions"?functionsPath():componentsPath()}export function unscopedName(name){return name.split("/").at(-1)??name}function includeFromFilesEntry(entry){const[file,alias]=Array.isArray(entry)?entry:[entry,void 0],stem=file.replace(/\.ts$/,""),include=stem==="*"?"*.ts":`${stem}.ts`;return alias?{include,alias:[stem,alias]}:{include}}function toDefinition(option,fallback){const name=option.name?.trim();if(!name)throw new LibraryConfigError(`library.packages[${fallback.index}] has no name. Every package needs the name it is published under.`);if(name.startsWith(".")||name.includes("\\")||name.split("/").length>2)throw new LibraryConfigError(`library.packages[${fallback.index}] has an invalid npm name: "${name}".`);const kind=option.kind??"functions";if(kind!=="functions"&&kind!=="components"&&kind!=="web-components")throw new LibraryConfigError(`Package "${name}" has an unknown kind "${kind}". Expected 'functions', 'components' or 'web-components'.`);const slug=(option.dir??unscopedName(name)).replace(/^@/,"");if(!/^[\w.-]+$/.test(slug))throw new LibraryConfigError(`Package "${name}" resolves to the directory "${slug}", which is not a single safe path segment. Set \`dir\` explicitly.`);const aliases={},includeFromFiles=[];for(const entry of option.files??[]){const{include,alias}=includeFromFilesEntry(entry);includeFromFiles.push(include);if(alias)aliases[alias[0]]=alias[1]}const names={};for(const tag of option.tags??[])if(Array.isArray(tag.name))names[tag.name[0]]=tag.name[1];const defaultInclude=kind==="functions"?DEFAULT_FUNCTION_INCLUDE:DEFAULT_COMPONENT_INCLUDE,defaultExclude=kind==="functions"?DEFAULT_FUNCTION_EXCLUDE:DEFAULT_COMPONENT_EXCLUDE,includeFromTags=option.tags?.length&&!option.include?.length?option.tags.map((tag)=>`${Array.isArray(tag.name)?tag.name[0]:tag.name}.stx`):[],include=option.include?.length?option.include:includeFromFiles.length?includeFromFiles:includeFromTags.length?includeFromTags:defaultInclude;return{name,kind,slug,description:option.description??`The ${name} library.`,keywords:option.keywords??[],license:option.license??fallback.license,version:option.version,private:option.private??!1,access:option.access??"public",registry:option.registry??"pantry",runtime:option.runtime??"standalone",sourcemap:option.shouldGenerateSourcemap??!1,include,exclude:option.exclude??defaultExclude,prefix:option.prefix??unscopedName(name).replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase(),dependencies:option.dependencies??{},peerDependencies:option.peerDependencies??{},aliases,names}}export function normalizeLibraryPackages(config){const cfg=config??{},options=[];if(cfg.packages?.length)options.push(...cfg.packages);else{if(cfg.functions?.name)options.push({...cfg.functions,kind:"functions"});if(cfg.webComponents?.name)options.push({...cfg.webComponents,kind:"web-components"})}const definitions=options.map((option,index)=>toDefinition(option,{license:cfg.license,index})),byName=new Map,bySlug=new Map;for(const definition of definitions){if(byName.has(definition.name))throw new LibraryConfigError(`Two packages are both named "${definition.name}". npm names must be unique.`);byName.set(definition.name,1);const owner=bySlug.get(definition.slug);if(owner)throw new LibraryConfigError(`"${owner}" and "${definition.name}" both build in storage/framework/libs/packages/${definition.slug}. Give one of them a \`dir\`.`);bySlug.set(definition.slug,definition.name)}return definitions}export async function resolveLibraryPackages(config,options={}){const definitions=normalizeLibraryPackages(config),resolved=[];for(const definition of definitions){const sourceDir=libraryPackageSourceDir(definition.kind),sources=await matchSources(sourceDir,definition.include,definition.exclude);if(!sources.length){if(options.onUnmatched==="skip")continue;throw new LibraryConfigError(`Package "${definition.name}" matched no files in ${relative(process.cwd(),sourceDir)} (include: ${definition.include.join(", ")}${definition.exclude.length?`; exclude: ${definition.exclude.join(", ")}`:""}).`)}resolved.push({...definition,sourceDir,sources,dir:libraryPackagePath(definition.slug),entry:libraryPackagePath(definition.slug,"src/index.ts")})}return resolved}export async function matchSources(sourceDir,include,exclude){if(!existsSync(sourceDir))return[];const expand=async(patterns)=>{const files=new Set;for(const pattern of patterns)for await(const file of new Bun.Glob(pattern).scan({cwd:sourceDir,absolute:!0,onlyFiles:!0}))files.add(resolve(file));return files},included=await expand(include),excluded=exclude.length?await expand(exclude):new Set;return[...included].filter((file)=>!excluded.has(file)).sort()}export function entrySpecifier(entry,source){const path=relative(resolve(entry,".."),source).replace(/\.ts$/,"");return path.startsWith(".")?path:`./${path}`}
@@ -7,27 +7,26 @@ import type { LibraryConfig } from '@stacksjs/types';
7
7
  * because the publish step ran with `--ignore-scripts` and nothing checked
8
8
  * that a build had happened first. This is that check, ahead of time.
9
9
  */
10
- export declare function planLibraryPublish(config?: LibraryConfig | undefined): Promise<LibraryPublishPlan[]>;
10
+ export declare function planLibraryPublish(config?: LibraryConfig): Promise<LibraryPublishPlan[]>;
11
11
  /**
12
- * The publisher to shell out to.
12
+ * The publisher to shell out to for a package bound for `registry`.
13
13
  *
14
14
  * `pantry publish` first. Pantry is this project's package manager, it is what
15
15
  * the release workflows already install, and it is the only one of the three
16
- * that publishes to the Pantry registry — a release that went out through
17
- * `bun publish` reached npm and nothing else, which is not where these
18
- * packages are meant to live.
16
+ * that publishes to the Pantry registry. A Pantry-bound package therefore
17
+ * needs it: falling back to `bun publish` sent such a release to npm and
18
+ * nowhere else, so that is refused rather than done quietly.
19
19
  *
20
- * It also takes the same flags this function's callers pass: `--access` and
21
- * `--dry-run` mean what they mean everywhere else, so nothing downstream has
22
- * to know which publisher was chosen. `--npm` is pantry's own escape hatch for
23
- * an npm-bound package; it belongs on the package, not here.
20
+ * An npm-bound package (`registry: 'npm'`) goes through `pantry publish --npm`,
21
+ * or `bun publish` and then `npm publish` when pantry is not installed. Neither
22
+ * of those is guaranteed present either (npm was not on the machine this was
23
+ * written on, and hardcoding it turned `libs:publish` into an ENOENT), so the
24
+ * choice is made from what is actually on PATH.
24
25
  *
25
- * `bun` and then `npm` remain as fallbacks. Neither is guaranteed present —
26
- * npm was not on the machine this was written on, and hardcoding it turned
27
- * `libs:publish` into an ENOENT — so the choice is made from what is actually
28
- * on PATH rather than assumed.
26
+ * Every publisher takes the flags the caller adds: `--access` and `--dry-run`
27
+ * mean the same thing to all three.
29
28
  */
30
- export declare function publishCommand(): string[];
29
+ export declare function publishCommand(registry?: 'pantry' | 'npm', which?: (bin: string) => string | null): string[];
31
30
  /**
32
31
  * Publish each built package.
33
32
  *
@@ -42,5 +41,6 @@ export declare interface LibraryPublishPlan {
42
41
  version: string
43
42
  dir: string
44
43
  access: 'public' | 'restricted'
44
+ registry: 'pantry' | 'npm'
45
45
  tarballFiles: number
46
46
  }
@@ -1,2 +1,2 @@
1
- import{existsSync}from"node:fs";import{relative,resolve}from"node:path";import{log}from"@stacksjs/logging";import{projectPath}from"@stacksjs/path";import{library}from"@stacksjs/config";import{LibraryConfigError,resolveLibraryPackages}from"./packages";export async function planLibraryPublish(config=library){const publishable=(await resolveLibraryPackages(config)).filter((pkg)=>!pkg.private);if(!publishable.length)throw new LibraryConfigError("Every configured library package is marked private. Nothing to publish.");const plans=[],missing=[];for(const pkg of publishable){const manifestPath=resolve(pkg.dir,"package.json"),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,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(){if(Bun.which("pantry"))return["pantry","publish"];if(Bun.which("bun"))return["bun","publish"];if(Bun.which("npm"))return["npm","publish"];throw 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??library),command=publishCommand();for(const plan of plans){const args=[...command,"--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 Error(`Publishing ${plan.name}@${plan.version} failed with exit code ${proc.exitCode}.`)}return plans}
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 publishable=(await resolveLibraryPackages(config??await configuredLibrary())).filter((pkg)=>!pkg.private);if(!publishable.length)throw new LibraryConfigError("Every configured library package is marked private. Nothing to publish.");const plans=[],missing=[];for(const pkg of publishable){const manifestPath=resolve(pkg.dir,"package.json"),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 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 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 Error(`Publishing ${plan.name}@${plan.version} failed with exit code ${proc.exitCode}.`)}return plans}
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.403",
5
+ "version": "0.75.405",
6
6
  "description": "The Stacks actions.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -66,58 +66,58 @@
66
66
  "prepublishOnly": "bun run build"
67
67
  },
68
68
  "dependencies": {
69
- "@stacksjs/action-runner": "0.75.403",
70
- "@stacksjs/ai": "0.75.403",
71
- "@stacksjs/analytics": "0.75.403",
72
- "@stacksjs/api": "0.75.403",
73
- "@stacksjs/auth": "0.75.403",
74
- "@stacksjs/build": "0.75.403",
69
+ "@stacksjs/action-runner": "0.75.405",
70
+ "@stacksjs/ai": "0.75.405",
71
+ "@stacksjs/analytics": "0.75.405",
72
+ "@stacksjs/api": "0.75.405",
73
+ "@stacksjs/auth": "0.75.405",
74
+ "@stacksjs/build": "0.75.405",
75
75
  "@stacksjs/bumpx": "^0.2.26",
76
76
  "@stacksjs/bunpress": "^0.2.15",
77
- "@stacksjs/cli": "0.75.403",
78
- "@stacksjs/cloud": "0.75.403",
79
- "@stacksjs/cms": "0.75.403",
80
- "@stacksjs/components": "0.2.776",
81
- "@stacksjs/config": "0.75.403",
82
- "@stacksjs/database": "0.75.403",
83
- "@stacksjs/desktop-build": "0.75.403",
84
- "@stacksjs/dns": "0.75.403",
85
- "@stacksjs/enums": "0.75.403",
86
- "@stacksjs/env": "0.75.403",
87
- "@stacksjs/error-handling": "0.75.403",
88
- "@stacksjs/github": "0.75.403",
77
+ "@stacksjs/cli": "0.75.405",
78
+ "@stacksjs/cloud": "0.75.405",
79
+ "@stacksjs/cms": "0.75.405",
80
+ "@stacksjs/components": "0.2.779",
81
+ "@stacksjs/config": "0.75.405",
82
+ "@stacksjs/database": "0.75.405",
83
+ "@stacksjs/desktop-build": "0.75.405",
84
+ "@stacksjs/dns": "0.75.405",
85
+ "@stacksjs/enums": "0.75.405",
86
+ "@stacksjs/env": "0.75.405",
87
+ "@stacksjs/error-handling": "0.75.405",
88
+ "@stacksjs/github": "0.75.405",
89
89
  "@stacksjs/gitit": "^0.2.5",
90
- "@stacksjs/i18n": "0.75.403",
91
- "@stacksjs/image": "0.75.403",
92
- "@stacksjs/logging": "0.75.403",
90
+ "@stacksjs/i18n": "0.75.405",
91
+ "@stacksjs/image": "0.75.405",
92
+ "@stacksjs/logging": "0.75.405",
93
93
  "@stacksjs/logsmith": "^0.2.11",
94
- "@stacksjs/mobile": "0.75.403",
95
- "@stacksjs/orm": "0.75.403",
96
- "@stacksjs/path": "0.75.403",
97
- "@stacksjs/payments": "0.75.403",
98
- "@stacksjs/queue": "0.75.403",
99
- "@stacksjs/registry": "0.75.403",
100
- "@stacksjs/router": "0.75.403",
94
+ "@stacksjs/mobile": "0.75.405",
95
+ "@stacksjs/orm": "0.75.405",
96
+ "@stacksjs/path": "0.75.405",
97
+ "@stacksjs/payments": "0.75.405",
98
+ "@stacksjs/queue": "0.75.405",
99
+ "@stacksjs/registry": "0.75.405",
100
+ "@stacksjs/router": "0.75.405",
101
101
  "@stacksjs/rpx": "^0.11.54",
102
- "@stacksjs/scheduler": "0.75.403",
103
- "@stacksjs/search-engine": "0.75.403",
104
- "@stacksjs/security": "0.75.403",
105
- "@stacksjs/server": "0.75.403",
106
- "@stacksjs/sites": "0.75.403",
107
- "@stacksjs/storage": "0.75.403",
108
- "@stacksjs/strings": "0.75.403",
109
- "@stacksjs/stx": "0.2.776",
102
+ "@stacksjs/scheduler": "0.75.405",
103
+ "@stacksjs/search-engine": "0.75.405",
104
+ "@stacksjs/security": "0.75.405",
105
+ "@stacksjs/server": "0.75.405",
106
+ "@stacksjs/sites": "0.75.405",
107
+ "@stacksjs/storage": "0.75.405",
108
+ "@stacksjs/strings": "0.75.405",
109
+ "@stacksjs/stx": "0.2.779",
110
110
  "@stacksjs/tlsx": "^0.13.19",
111
111
  "@stacksjs/ts-cloud": "^0.16.91",
112
112
  "@stacksjs/ts-md": "^0.1.1",
113
- "@stacksjs/tunnel": "0.75.403",
114
- "@stacksjs/types": "0.75.403",
115
- "@stacksjs/utils": "0.75.403",
116
- "@stacksjs/whois": "0.75.403",
117
- "bun-plugin-stx": "0.2.776"
113
+ "@stacksjs/tunnel": "0.75.405",
114
+ "@stacksjs/types": "0.75.405",
115
+ "@stacksjs/utils": "0.75.405",
116
+ "@stacksjs/whois": "0.75.405",
117
+ "bun-plugin-stx": "0.2.779"
118
118
  },
119
119
  "peerDependencies": {
120
- "craft-native": ">=0.0.411",
120
+ "craft-native": ">=0.0.416",
121
121
  "pickier": "^0.1.75"
122
122
  },
123
123
  "peerDependenciesMeta": {
@@ -129,7 +129,7 @@
129
129
  }
130
130
  },
131
131
  "devDependencies": {
132
- "@stacksjs/validation": "0.75.403",
132
+ "@stacksjs/validation": "0.75.405",
133
133
  "better-dx": "^0.2.24"
134
134
  }
135
135
  }