@stacksjs/actions 0.75.409 → 0.75.417

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import{existsSync,mkdirSync,mkdtempSync,readFileSync,rmSync}from"node:fs";import{tmpdir}from"node:os";import{join}from"node:path";import process from"node:process";import{log,parseOptions}from"@stacksjs/cli";import{developerIdProblem,loadMacosDesktop,macosOutputDirectory,resolveDmgPackaging}from"@stacksjs/desktop-build";import{projectPath,storagePath}from"@stacksjs/path";import{imageDmg,notarizeAndStaple,notaryArguments}from"./notarize";import{runBuildStep}from"./run-build-step";if(process.platform!=="darwin")throw Error("DMG packaging only runs on macOS");const root=projectPath(),pkg=existsSync(join(root,"package.json"))?JSON.parse(readFileSync(join(root,"package.json"),"utf8")):{},config=await loadMacosDesktop(root,pkg.version);if(!config)throw Error("config/desktop.ts has no macos section, so build:dmg packages the Craft web-view app instead.");const flags=parseOptions();for(const[flag,name]of[["appName","--app-name"],["bundleId","--bundle-id"],["appVersion","--app-version"]])if(flags[flag]!==void 0)await log.warn(`${name} is ignored: config/desktop.ts names, identifies and versions a macos app.`);const{volumeName,signingIdentity,notary}=resolveDmgPackaging({flags:{...flags,appName:void 0,bundleId:void 0,appVersion:void 0},env:{...process.env,DESKTOP_APP_NAME:void 0,DESKTOP_BUNDLE_ID:void 0,DESKTOP_APP_VERSION:void 0},manifestTitle:config.appName,declaredVersion:config.version});if(notary&&!signingIdentity)throw Error("Notarizing needs a Developer ID identity (--signing-identity or DESKTOP_SIGNING_IDENTITY): Apple only notarizes signed code.");if(signingIdentity)process.env.DESKTOP_SIGNING_IDENTITY=signingIdentity;await import("./desktop-macos");const app=join(macosOutputDirectory(root,config),`${config.appName}.app`);if(!existsSync(app))throw Error(`build:desktop did not produce ${app}`);if(notary){const signature=Bun.spawnSync(["codesign","-dvv",app],{stderr:"pipe"}),problem=developerIdProblem(`${signature.stdout.toString()}${signature.stderr.toString()}`);if(problem)throw Error(`${app} cannot be notarized: ${problem}`)}const outputDir=storagePath("framework/desktop-dmg");rmSync(outputDir,{recursive:!0,force:!0});mkdirSync(outputDir,{recursive:!0});const staging=mkdtempSync(join(tmpdir(),"stacks-dmg-")),scratch=mkdtempSync(join(tmpdir(),"stacks-dmg-work-"));process.on("exit",()=>{rmSync(staging,{recursive:!0,force:!0});rmSync(scratch,{recursive:!0,force:!0})});const auth=notary&&notaryArguments(notary);if(auth)await notarizeAndStaple(app,`${config.appName}.app`,auth,scratch);await runBuildStep(["ditto",app,join(staging,`${config.appName}.app`)],{cwd:staging,describe:`Staging ${config.appName}.app`});const dmgPath=join(outputDir,`${config.appName}-${config.version}.dmg`);await imageDmg({staging,volumeName,dmgPath,signingIdentity});if(auth){await notarizeAndStaple(dmgPath,"the DMG",auth,scratch);await log.success("Notarized and stapled")}await log.success(`Built ${dmgPath}`);if(!signingIdentity)await log.info("Signed for development only: other Macs refuse it. Pass --signing-identity with a Developer ID identity, and --notarize, before distributing.");else if(!auth)await log.info("Signed but not notarized: other Macs still warn on first open. Pass --notary-profile, or --notarize with an App Store Connect API key.");
package/dist/build/dmg.js CHANGED
@@ -1,2 +1 @@
1
- import{cpSync,existsSync,mkdirSync,mkdtempSync,readdirSync,readFileSync,rmSync,statSync,symlinkSync,writeFileSync}from"node:fs";import{tmpdir}from"node:os";import{basename,dirname,join}from"node:path";import process from"node:process";import{log,parseOptions,runCommand}from"@stacksjs/cli";import{appPath,projectPath,publicPath,resourcesPath,storagePath}from"@stacksjs/path";import{bundleDirectoryFor,codesignArgs,describeRuntimeDuplication,looksLikeBunExecutable,notarytoolAuthArgs,renderInfoPlist,resolveDmgPackaging}from"@stacksjs/desktop-build";import{runBuildStep}from"./run-build-step";if(process.platform!=="darwin")throw Error("DMG packaging only runs on macOS");const desktopDist=storagePath("framework/desktop-dist"),manifestPath=join(desktopDist,"desktop.json");if(!existsSync(manifestPath)){log.info("No desktop build found. Building it first (`build:desktop`).");await import("./desktop")}if(!existsSync(manifestPath))throw Error(`build:desktop ran but left no manifest at ${manifestPath}`);const manifest=JSON.parse(readFileSync(manifestPath,"utf8")),ownsLauncher=manifest.launcher==="userland";function declaredProjectVersion(){const packageJson=projectPath("package.json");if(!existsSync(packageJson))return;try{return JSON.parse(readFileSync(packageJson,"utf8")).version}catch{return}}const{appName,bundleId,version,volumeName,signingIdentity,notary}=resolveDmgPackaging({flags:parseOptions(),env:process.env,manifestTitle:manifest.title,declaredVersion:declaredProjectVersion()}),outputDir=storagePath("framework/desktop-dmg");if(existsSync(outputDir))rmSync(outputDir,{recursive:!0});mkdirSync(outputDir,{recursive:!0});const staging=mkdtempSync(join(tmpdir(),"stacks-dmg-")),scratch=mkdtempSync(join(tmpdir(),"stacks-dmg-work-"));process.on("exit",()=>{rmSync(staging,{recursive:!0,force:!0});rmSync(scratch,{recursive:!0,force:!0})});const appDir=join(staging,`${appName}.app`),macosDir=join(appDir,"Contents/MacOS"),resourcesDir=join(appDir,"Contents/Resources");mkdirSync(macosDir,{recursive:!0});mkdirSync(resourcesDir,{recursive:!0});const builtLauncher="stacks-desktop",launcherName=appName,bundledFiles=readdirSync(desktopDist).filter((name)=>statSync(join(desktopDist,name)).isFile());for(const file of bundledFiles){const target=file===builtLauncher?launcherName:file,directory=bundleDirectoryFor(join(desktopDist,file))==="MacOS"?macosDir:resourcesDir;await runBuildStep(["cp",join(desktopDist,file),join(directory,target)],{cwd:projectPath(),describe:`Copying ${file} into the bundle`})}if(!existsSync(join(macosDir,launcherName)))throw Error(`build:desktop did not produce ${builtLauncher}`);const runtimes=readdirSync(macosDir).filter((name)=>statSync(join(macosDir,name)).isFile()).filter((name)=>looksLikeBunExecutable(join(macosDir,name))).map((name)=>({name,bytes:statSync(join(macosDir,name)).size})),duplication=describeRuntimeDuplication(runtimes);if(duplication)log.warn(duplication);const userlandResources=appPath("Desktop/Resources");if(existsSync(userlandResources))cpSync(userlandResources,resourcesDir,{recursive:!0});async function buildIcon(){const source=[resourcesPath("assets/images/app-icon.png"),publicPath("images/app-icon.png"),publicPath("apple-touch-icon.png")].find((candidate)=>existsSync(candidate));if(!source)return;const iconset=join(scratch,"icon.iconset");mkdirSync(iconset,{recursive:!0});for(const size of[16,32,128,256,512]){await runCommand(["sips","-z",String(size),String(size),source,"--out",join(iconset,`icon_${size}x${size}.png`)],{cwd:scratch,silent:!0});await runCommand(["sips","-z",String(size*2),String(size*2),source,"--out",join(iconset,`icon_${size}x${size}@2x.png`)],{cwd:scratch,silent:!0})}const icns=join(resourcesDir,"AppIcon.icns");if((await runCommand(["iconutil","-c","icns",iconset,"-o",icns],{cwd:scratch})).isErr||!existsSync(icns)){log.warn(`Could not build an .icns from ${source}; the bundle will use the default icon.`);return}return"AppIcon"}const iconFile=await buildIcon();function readUserlandPlist(){const declared=appPath("Desktop/Info.plist.json");if(!existsSync(declared))return{};try{return JSON.parse(readFileSync(declared,"utf8"))}catch(error){throw Error(`app/Desktop/Info.plist.json is not valid JSON: ${error instanceof Error?error.message:error}`)}}const declaredPlist=readUserlandPlist(),{xml:infoPlist,ignored:ignoredPlistKeys}=renderInfoPlist({appName,bundleId,version,executable:launcherName,iconFile,ownsLauncher,declared:declaredPlist});if(ignoredPlistKeys.length>0)log.info(`Ignoring reserved Info.plist keys from app/Desktop/Info.plist.json: ${ignoredPlistKeys.join(", ")}`);const infoPlistPath=join(appDir,"Contents/Info.plist");writeFileSync(infoPlistPath,infoPlist);const linted=Bun.spawnSync(["plutil","-lint",infoPlistPath],{stdout:"pipe",stderr:"pipe"});if(linted.exitCode!==0)throw Error(`Generated an Info.plist that macOS cannot read: ${`${linted.stdout.toString()}${linted.stderr.toString()}`.trim()}`);if(signingIdentity){const nested=readdirSync(macosDir).filter((name)=>name!==launcherName).map((name)=>join(macosDir,name)),declaredEntitlements=appPath("Desktop/Entitlements.plist"),entitlements=existsSync(declaredEntitlements)?declaredEntitlements:void 0;for(const target of[...nested,join(macosDir,launcherName),appDir])await runBuildStep(codesignArgs({identity:signingIdentity,target,entitlements}),{cwd:staging,describe:`Signing ${basename(target)}`})}async function notarize(target,what){if(!signingIdentity)throw Error("Notarizing needs a signing identity (--signing-identity or DESKTOP_SIGNING_IDENTITY): Apple only notarizes signed code.");const upload=target.endsWith(".app")?join(scratch,`${basename(target)}.zip`):target;if(upload!==target)await runBuildStep(["ditto","-c","-k","--keepParent",target,upload],{cwd:scratch,describe:`Zipping ${basename(target)} for notarization`});log.info(`Notarizing ${what} (Apple usually answers within a few minutes)...`);const submitted=Bun.spawnSync(["xcrun","notarytool","submit",upload,...notaryAuth,"--wait"],{stderr:"pipe"}),report=`${submitted.stdout.toString()}${submitted.stderr.toString()}`,status=report.match(/status: (\w[\w ]*)/g)?.pop()?.replace("status: ","");if(submitted.exitCode!==0||status!=="Accepted"){console.error(report.trim());const id=report.match(/id: ([0-9a-f-]{36})/)?.[1];throw Error(`Notarization of ${what} ${status??"failed"}${id?` - see \`xcrun notarytool log ${id} ${notaryAuth.join(" ")}\``:""}`)}await runBuildStep(["xcrun","stapler","staple",target],{cwd:dirname(target),describe:`Stapling the notarization ticket to ${what}`})}const notaryAuth=notary&&notarytoolAuthArgs("keyPem"in notary?{...notary,keyPath:privateKeyFile(notary.keyId,notary.keyPem)}:notary);function privateKeyFile(keyId,pem){const directory=mkdtempSync(join(tmpdir(),"stacks-notary-key-")),path=join(directory,`AuthKey_${keyId}.p8`);writeFileSync(path,`${pem}
2
- `,{mode:384});process.on("exit",()=>rmSync(directory,{recursive:!0,force:!0}));return path}if(notaryAuth)await notarize(appDir,basename(appDir));symlinkSync("/Applications",join(staging,"Applications"));const dmgPath=join(outputDir,`${appName}-${version}.dmg`);if(volumeName===appName)log.warn(`The volume name is the app's own name, so the bundle stages at /Volumes/${appName}/${appName}.app. That path is refused on a Mac where ${appName} is already installed; drop --volume-name / DESKTOP_VOLUME_NAME to get "${appName} ${version}".`);const created=await runCommand(["hdiutil","create","-volname",volumeName,"-srcfolder",staging,"-ov","-format","UDZO",dmgPath],{cwd:staging});if(created.isErr)throw Error(`hdiutil failed to create ${dmgPath}`);rmSync(staging,{recursive:!0,force:!0});rmSync(scratch,{recursive:!0,force:!0});if(signingIdentity)await runBuildStep(["codesign","--force","--timestamp","--sign",signingIdentity,dmgPath],{cwd:outputDir,describe:"Signing the DMG"});if(notaryAuth){await notarize(dmgPath,"the DMG");log.success("Notarized and stapled")}log.success(`Built ${dmgPath}`);if(!signingIdentity)log.info("Unsigned build: Gatekeeper blocks the first launch. Right-click the app and choose Open, or pass --signing-identity and --notarize before distributing.");else if(!notaryAuth)log.info("Signed but not notarized: other Macs still warn on first open. Pass --notary-profile, or --notarize with an App Store Connect API key.");
1
+ import{cpSync,existsSync,mkdirSync,mkdtempSync,readdirSync,readFileSync,rmSync,statSync,writeFileSync}from"node:fs";import{tmpdir}from"node:os";import{basename,join}from"node:path";import process from"node:process";import{log,parseOptions,runCommand}from"@stacksjs/cli";import{appPath,projectPath,publicPath,resourcesPath,storagePath}from"@stacksjs/path";import{bundleDirectoryFor,codesignArgs,describeRuntimeDuplication,looksLikeBunExecutable,renderInfoPlist,resolveDmgPackaging}from"@stacksjs/desktop-build";import{imageDmg,notarizeAndStaple,notaryArguments}from"./notarize";import{runBuildStep}from"./run-build-step";if(process.platform!=="darwin")throw Error("DMG packaging only runs on macOS");const desktopDist=storagePath("framework/desktop-dist"),manifestPath=join(desktopDist,"desktop.json");if(!existsSync(manifestPath)){log.info("No desktop build found. Building it first (`build:desktop`).");await import("./desktop")}if(!existsSync(manifestPath))throw Error(`build:desktop ran but left no manifest at ${manifestPath}`);const manifest=JSON.parse(readFileSync(manifestPath,"utf8")),ownsLauncher=manifest.launcher==="userland";function declaredProjectVersion(){const packageJson=projectPath("package.json");if(!existsSync(packageJson))return;try{return JSON.parse(readFileSync(packageJson,"utf8")).version}catch{return}}const{appName,bundleId,version,volumeName,signingIdentity,notary}=resolveDmgPackaging({flags:parseOptions(),env:process.env,manifestTitle:manifest.title,declaredVersion:declaredProjectVersion()}),outputDir=storagePath("framework/desktop-dmg");if(existsSync(outputDir))rmSync(outputDir,{recursive:!0});mkdirSync(outputDir,{recursive:!0});const staging=mkdtempSync(join(tmpdir(),"stacks-dmg-")),scratch=mkdtempSync(join(tmpdir(),"stacks-dmg-work-"));process.on("exit",()=>{rmSync(staging,{recursive:!0,force:!0});rmSync(scratch,{recursive:!0,force:!0})});const appDir=join(staging,`${appName}.app`),macosDir=join(appDir,"Contents/MacOS"),resourcesDir=join(appDir,"Contents/Resources");mkdirSync(macosDir,{recursive:!0});mkdirSync(resourcesDir,{recursive:!0});const builtLauncher="stacks-desktop",launcherName=appName,bundledFiles=readdirSync(desktopDist).filter((name)=>statSync(join(desktopDist,name)).isFile());for(const file of bundledFiles){const target=file===builtLauncher?launcherName:file,directory=bundleDirectoryFor(join(desktopDist,file))==="MacOS"?macosDir:resourcesDir;await runBuildStep(["cp",join(desktopDist,file),join(directory,target)],{cwd:projectPath(),describe:`Copying ${file} into the bundle`})}if(!existsSync(join(macosDir,launcherName)))throw Error(`build:desktop did not produce ${builtLauncher}`);const runtimes=readdirSync(macosDir).filter((name)=>statSync(join(macosDir,name)).isFile()).filter((name)=>looksLikeBunExecutable(join(macosDir,name))).map((name)=>({name,bytes:statSync(join(macosDir,name)).size})),duplication=describeRuntimeDuplication(runtimes);if(duplication)log.warn(duplication);const userlandResources=appPath("Desktop/Resources");if(existsSync(userlandResources))cpSync(userlandResources,resourcesDir,{recursive:!0});async function buildIcon(){const source=[resourcesPath("assets/images/app-icon.png"),publicPath("images/app-icon.png"),publicPath("apple-touch-icon.png")].find((candidate)=>existsSync(candidate));if(!source)return;const iconset=join(scratch,"icon.iconset");mkdirSync(iconset,{recursive:!0});for(const size of[16,32,128,256,512]){await runCommand(["sips","-z",String(size),String(size),source,"--out",join(iconset,`icon_${size}x${size}.png`)],{cwd:scratch,silent:!0});await runCommand(["sips","-z",String(size*2),String(size*2),source,"--out",join(iconset,`icon_${size}x${size}@2x.png`)],{cwd:scratch,silent:!0})}const icns=join(resourcesDir,"AppIcon.icns");if((await runCommand(["iconutil","-c","icns",iconset,"-o",icns],{cwd:scratch})).isErr||!existsSync(icns)){log.warn(`Could not build an .icns from ${source}; the bundle will use the default icon.`);return}return"AppIcon"}const iconFile=await buildIcon();function readUserlandPlist(){const declared=appPath("Desktop/Info.plist.json");if(!existsSync(declared))return{};try{return JSON.parse(readFileSync(declared,"utf8"))}catch(error){throw Error(`app/Desktop/Info.plist.json is not valid JSON: ${error instanceof Error?error.message:error}`)}}const declaredPlist=readUserlandPlist(),{xml:infoPlist,ignored:ignoredPlistKeys}=renderInfoPlist({appName,bundleId,version,executable:launcherName,iconFile,ownsLauncher,declared:declaredPlist});if(ignoredPlistKeys.length>0)log.info(`Ignoring reserved Info.plist keys from app/Desktop/Info.plist.json: ${ignoredPlistKeys.join(", ")}`);const infoPlistPath=join(appDir,"Contents/Info.plist");writeFileSync(infoPlistPath,infoPlist);const linted=Bun.spawnSync(["plutil","-lint",infoPlistPath],{stdout:"pipe",stderr:"pipe"});if(linted.exitCode!==0)throw Error(`Generated an Info.plist that macOS cannot read: ${`${linted.stdout.toString()}${linted.stderr.toString()}`.trim()}`);if(signingIdentity){const nested=readdirSync(macosDir).filter((name)=>name!==launcherName).map((name)=>join(macosDir,name)),declaredEntitlements=appPath("Desktop/Entitlements.plist"),entitlements=existsSync(declaredEntitlements)?declaredEntitlements:void 0;for(const target of[...nested,join(macosDir,launcherName),appDir])await runBuildStep(codesignArgs({identity:signingIdentity,target,entitlements}),{cwd:staging,describe:`Signing ${basename(target)}`})}const notaryAuth=notary&&notaryArguments(notary);if(notaryAuth&&!signingIdentity)throw Error("Notarizing needs a signing identity (--signing-identity or DESKTOP_SIGNING_IDENTITY): Apple only notarizes signed code.");if(notaryAuth)await notarizeAndStaple(appDir,basename(appDir),notaryAuth,scratch);const dmgPath=join(outputDir,`${appName}-${version}.dmg`);if(volumeName===appName)log.warn(`The volume name is the app's own name, so the bundle stages at /Volumes/${appName}/${appName}.app. That path is refused on a Mac where ${appName} is already installed; drop --volume-name / DESKTOP_VOLUME_NAME to get "${appName} ${version}".`);await imageDmg({staging,volumeName,dmgPath,signingIdentity});rmSync(staging,{recursive:!0,force:!0});if(notaryAuth){await notarizeAndStaple(dmgPath,"the DMG",notaryAuth,scratch);log.success("Notarized and stapled")}log.success(`Built ${dmgPath}`);if(!signingIdentity)log.info("Unsigned build: Gatekeeper blocks the first launch. Right-click the app and choose Open, or pass --signing-identity and --notarize before distributing.");else if(!notaryAuth)log.info("Signed but not notarized: other Macs still warn on first open. Pass --notary-profile, or --notarize with an App Store Connect API key.");
@@ -0,0 +1,29 @@
1
+ import type { NotaryCredentials } from '@stacksjs/desktop-build';
2
+ /**
3
+ * The steps every direct-distribution Mac build ends with, shared by
4
+ * `build/dmg.ts` (the Craft web-view app) and `build/dmg-macos.ts` (a
5
+ * `config/desktop.ts` `macos` app): submit to Apple's notary service and
6
+ * staple, and image a folder into a signed DMG.
7
+ */
8
+ /**
9
+ * notarytool's arguments for `credentials`. A key held as PEM text (an
10
+ * encrypted `.env.production` value) goes to a private file for this run:
11
+ * notarytool reads keys from disk only.
12
+ */
13
+ export declare function notaryArguments(credentials: NotaryCredentials): string[];
14
+ /**
15
+ * Submit `target` to Apple's notary service, wait, and staple the ticket to it.
16
+ * A stapled ticket lets Gatekeeper accept the file offline; an app is
17
+ * notarized on its own as well as in its DMG, because once someone drags it
18
+ * out of the image only the app's own ticket travels with it.
19
+ *
20
+ * notarytool takes a zip, dmg or pkg, not a bare `.app`, so an app is zipped
21
+ * into `scratch` first.
22
+ */
23
+ export declare function notarizeAndStaple(target: string, what: string, auth: string[], scratch: string): Promise<void>;
24
+ /**
25
+ * Image `staging` (which must hold only the `.app`) into `dmgPath`, with the
26
+ * `/Applications` link every macOS DMG is expected to have, and sign the image:
27
+ * Gatekeeper checks the DMG a person opens before it ever looks at the app.
28
+ */
29
+ export declare function imageDmg(options: { staging: string, volumeName: string, dmgPath: string, signingIdentity?: string }): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import{mkdtempSync,rmSync,symlinkSync,writeFileSync}from"node:fs";import{tmpdir}from"node:os";import{basename,dirname,join}from"node:path";import process from"node:process";import{log,runCommand}from"@stacksjs/cli";import{notarizationOutcome,notarytoolAuthArgs}from"@stacksjs/desktop-build";import{runBuildStep}from"./run-build-step";export function notaryArguments(credentials){if(!("keyPem"in credentials))return notarytoolAuthArgs(credentials);const directory=mkdtempSync(join(tmpdir(),"stacks-notary-key-")),keyPath=join(directory,`AuthKey_${credentials.keyId}.p8`);writeFileSync(keyPath,`${credentials.keyPem}
2
+ `,{mode:384});process.on("exit",()=>rmSync(directory,{recursive:!0,force:!0}));return notarytoolAuthArgs({keyId:credentials.keyId,issuerId:credentials.issuerId,keyPath})}export async function notarizeAndStaple(target,what,auth,scratch){const upload=target.endsWith(".app")?join(scratch,`${basename(target)}.zip`):target;if(upload!==target)await runBuildStep(["ditto","-c","-k","--keepParent",target,upload],{cwd:scratch,describe:`Zipping ${basename(target)} for notarization`});log.info(`Notarizing ${what} (Apple usually answers within a few minutes)...`);const submitted=Bun.spawnSync(["xcrun","notarytool","submit",upload,...auth,"--wait"],{stderr:"pipe"}),report=`${submitted.stdout.toString()}${submitted.stderr.toString()}`,outcome=notarizationOutcome(report,submitted.exitCode);if(!outcome.accepted){console.error(report.trim());throw Error(`Notarization of ${what} ${outcome.status??"failed"}${outcome.id?` - see \`xcrun notarytool log ${outcome.id} ${auth.join(" ")}\``:""}`)}await runBuildStep(["xcrun","stapler","staple",target],{cwd:dirname(target),describe:`Stapling the notarization ticket to ${what}`})}export async function imageDmg(options){symlinkSync("/Applications",join(options.staging,"Applications"));if((await runCommand(["hdiutil","create","-volname",options.volumeName,"-srcfolder",options.staging,"-ov","-format","UDZO",options.dmgPath],{cwd:options.staging})).isErr)throw Error(`hdiutil failed to create ${options.dmgPath}`);if(options.signingIdentity)await runBuildStep(["codesign","--force","--timestamp","--sign",options.signingIdentity,options.dmgPath],{cwd:dirname(options.dmgPath),describe:"Signing the DMG"})}
@@ -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{log}from"@stacksjs/logging";import{projectPath}from"@stacksjs/path";import{buildComponentLibrary}from"@stacksjs/stx";import{functionEntryData}from"./entries";import{ambientGlobalsUsed,stxAmbientGlobals}from"./globals";import{generatedReadme,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:
1
+ import{existsSync}from"node:fs";import{cp,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{generatedReadme,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(compile)runPrebuild(pkg);if(pkg.kind==="functions")await buildFunctionPackage(pkg,config,version,compile);else await buildComponentPackage(pkg,config,version,compile);if(compile)await copyAssets(pkg);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)}function runPrebuild(pkg){if(!pkg.prebuild)return;log.info(`${pkg.name}: ${pkg.prebuild}`);const proc=Bun.spawnSync({cmd:["sh","-c",pkg.prebuild],cwd:projectPath(),stdout:"inherit",stderr:"inherit"});if(proc.exitCode!==0)throw new LibraryConfigError(`Package "${pkg.name}": prebuild \`${pkg.prebuild}\` exited with code ${proc.exitCode}.`)}async function copyAssets(pkg){for(const asset of pkg.assets){const source=projectPath(asset.source),destination=resolve(pkg.dir,"dist",asset.dest);if(!existsSync(source))throw new LibraryConfigError(`Package "${pkg.name}" ships "${asset.source}" as ${asset.dest}, but it does not exist.`+(pkg.prebuild?" The prebuild command did not produce it.":" Build it first, or set `prebuild` to the command that does."));if(existsSync(destination))throw new LibraryConfigError(`Package "${pkg.name}": asset ${asset.dest} collides with a file the build wrote to dist/${asset.dest}.`);await mkdir(dirname(destination),{recursive:!0});await cp(source,destination,{recursive:!0})}}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
 
@@ -36,5 +36,5 @@ export declare interface LibraryManifest {
36
36
  dependencies?: Record<string, string>
37
37
  peerDependencies?: Record<string, string>
38
38
  publishConfig?: { access: 'public' | 'restricted' }
39
- stacks: { kind: string, sources: string[], runtime?: 'standalone' | 'stx' }
39
+ stacks: { kind: string, sources: string[], assets?: string[], runtime?: 'standalone' | 'stx' }
40
40
  }
@@ -1,3 +1,3 @@
1
1
  export function generatedReadme(pkg,config){const lines=[`# ${pkg.name}`,"",pkg.description,"","## Install","","```sh",`bun add ${pkg.name}`,"```",""],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??{},repository=cfg.repository,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`:void 0,repository:repository?{type:"git",url:`git+https://github.com/${repository}.git`}:void 0,bugs:repository?{url:`https://github.com/${repository}/issues`}:void 0,keywords:pkg.keywords.length?pkg.keywords:void 0,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:void 0,peerDependencies:Object.keys(pkg.peerDependencies).length?pkg.peerDependencies:void 0,stacks:{kind:pkg.kind,sources:sourcesRelativeToProject}};if(pkg.private)manifest.private=!0;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"}return manifest}export function serializeManifest(manifest){return`${JSON.stringify(manifest,(_key,value)=>value===void 0?void 0:value,2)}
2
+ `)}export function libraryManifest(pkg,config,version,sourcesRelativeToProject){const cfg=config??{},repository=cfg.repository,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`:void 0,repository:repository?{type:"git",url:`git+https://github.com/${repository}.git`}:void 0,bugs:repository?{url:`https://github.com/${repository}/issues`}:void 0,keywords:pkg.keywords.length?pkg.keywords:void 0,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:void 0,peerDependencies:Object.keys(pkg.peerDependencies).length?pkg.peerDependencies:void 0,stacks:{kind:pkg.kind,sources:sourcesRelativeToProject}};if(pkg.private)manifest.private=!0;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??[],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===void 0?void 0:value,2)}
3
3
  `}
@@ -63,6 +63,8 @@ export declare interface LibraryPackageDefinition {
63
63
  access: 'public' | 'restricted'
64
64
  registry: 'pantry' | 'npm'
65
65
  readme?: string
66
+ assets: Array<{ dest: string, source: string }>
67
+ prebuild?: string
66
68
  runtime: 'standalone' | 'stx'
67
69
  sourcemap: boolean
68
70
  include: string[]
@@ -1 +1 @@
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",readme:option.readme,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,assets=Object.entries(option.assets??{}).map(([dest,source])=>{const clean=dest.replace(/^\.\//,"").replace(/\/+$/,"");if(!clean||clean.startsWith("/")||clean.split("/").some((part)=>part===".."||part==="."||part===""))throw new LibraryConfigError(`Package "${name}" has an asset path "${dest}" that is not a plain path inside the package.`);if(/^index(\.d)?\.[cm]?[jt]s$/.test(clean)||clean==="bundle.js"||clean==="bundle.css")throw new LibraryConfigError(`Package "${name}" has an asset at "${dest}", which the build itself writes.`);if(!source||typeof source!=="string")throw new LibraryConfigError(`Package "${name}" has an asset "${dest}" with no source path.`);return{dest:clean,source}});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",readme:option.readme,assets,prebuild:option.prebuild,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}`}
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.409",
5
+ "version": "0.75.417",
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.409",
70
- "@stacksjs/ai": "0.75.409",
71
- "@stacksjs/analytics": "0.75.409",
72
- "@stacksjs/api": "0.75.409",
73
- "@stacksjs/auth": "0.75.409",
74
- "@stacksjs/build": "0.75.409",
69
+ "@stacksjs/action-runner": "0.75.417",
70
+ "@stacksjs/ai": "0.75.417",
71
+ "@stacksjs/analytics": "0.75.417",
72
+ "@stacksjs/api": "0.75.417",
73
+ "@stacksjs/auth": "0.75.417",
74
+ "@stacksjs/build": "0.75.417",
75
75
  "@stacksjs/bumpx": "^0.2.26",
76
76
  "@stacksjs/bunpress": "^0.2.15",
77
- "@stacksjs/cli": "0.75.409",
78
- "@stacksjs/cloud": "0.75.409",
79
- "@stacksjs/cms": "0.75.409",
77
+ "@stacksjs/cli": "0.75.417",
78
+ "@stacksjs/cloud": "0.75.417",
79
+ "@stacksjs/cms": "0.75.417",
80
80
  "@stacksjs/components": "0.2.780",
81
- "@stacksjs/config": "0.75.409",
82
- "@stacksjs/database": "0.75.409",
83
- "@stacksjs/desktop-build": "0.75.409",
84
- "@stacksjs/dns": "0.75.409",
85
- "@stacksjs/enums": "0.75.409",
86
- "@stacksjs/env": "0.75.409",
87
- "@stacksjs/error-handling": "0.75.409",
88
- "@stacksjs/github": "0.75.409",
81
+ "@stacksjs/config": "0.75.417",
82
+ "@stacksjs/database": "0.75.417",
83
+ "@stacksjs/desktop-build": "0.75.417",
84
+ "@stacksjs/dns": "0.75.417",
85
+ "@stacksjs/enums": "0.75.417",
86
+ "@stacksjs/env": "0.75.417",
87
+ "@stacksjs/error-handling": "0.75.417",
88
+ "@stacksjs/github": "0.75.417",
89
89
  "@stacksjs/gitit": "^0.2.5",
90
- "@stacksjs/i18n": "0.75.409",
91
- "@stacksjs/image": "0.75.409",
92
- "@stacksjs/logging": "0.75.409",
90
+ "@stacksjs/i18n": "0.75.417",
91
+ "@stacksjs/image": "0.75.417",
92
+ "@stacksjs/logging": "0.75.417",
93
93
  "@stacksjs/logsmith": "^0.2.11",
94
- "@stacksjs/mobile": "0.75.409",
95
- "@stacksjs/orm": "0.75.409",
96
- "@stacksjs/path": "0.75.409",
97
- "@stacksjs/payments": "0.75.409",
98
- "@stacksjs/queue": "0.75.409",
99
- "@stacksjs/registry": "0.75.409",
100
- "@stacksjs/router": "0.75.409",
94
+ "@stacksjs/mobile": "0.75.417",
95
+ "@stacksjs/orm": "0.75.417",
96
+ "@stacksjs/path": "0.75.417",
97
+ "@stacksjs/payments": "0.75.417",
98
+ "@stacksjs/queue": "0.75.417",
99
+ "@stacksjs/registry": "0.75.417",
100
+ "@stacksjs/router": "0.75.417",
101
101
  "@stacksjs/rpx": "^0.11.54",
102
- "@stacksjs/scheduler": "0.75.409",
103
- "@stacksjs/search-engine": "0.75.409",
104
- "@stacksjs/security": "0.75.409",
105
- "@stacksjs/server": "0.75.409",
106
- "@stacksjs/sites": "0.75.409",
107
- "@stacksjs/storage": "0.75.409",
108
- "@stacksjs/strings": "0.75.409",
102
+ "@stacksjs/scheduler": "0.75.417",
103
+ "@stacksjs/search-engine": "0.75.417",
104
+ "@stacksjs/security": "0.75.417",
105
+ "@stacksjs/server": "0.75.417",
106
+ "@stacksjs/sites": "0.75.417",
107
+ "@stacksjs/storage": "0.75.417",
108
+ "@stacksjs/strings": "0.75.417",
109
109
  "@stacksjs/stx": "0.2.780",
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.409",
114
- "@stacksjs/types": "0.75.409",
115
- "@stacksjs/utils": "0.75.409",
116
- "@stacksjs/whois": "0.75.409",
113
+ "@stacksjs/tunnel": "0.75.417",
114
+ "@stacksjs/types": "0.75.417",
115
+ "@stacksjs/utils": "0.75.417",
116
+ "@stacksjs/whois": "0.75.417",
117
117
  "bun-plugin-stx": "0.2.780"
118
118
  },
119
119
  "peerDependencies": {
@@ -129,7 +129,7 @@
129
129
  }
130
130
  },
131
131
  "devDependencies": {
132
- "@stacksjs/validation": "0.75.409",
132
+ "@stacksjs/validation": "0.75.417",
133
133
  "better-dx": "^0.2.24"
134
134
  }
135
135
  }