@stacksjs/utils 0.75.220 → 0.75.222

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/helpers.d.ts CHANGED
@@ -20,7 +20,7 @@ export declare function isAppKeySet(): Promise<boolean>;
20
20
  /**
21
21
  * Determines the utilized reset preset.
22
22
  *
23
- * @url https://github.com/cwcss/crosswind
23
+ * @url https://github.com/stacksjs/ts-css
24
24
  * @param preset
25
25
  */
26
26
  export declare function determineResetPreset(preset?: string | null): string[];
package/dist/helpers.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import process from"node:process";import{runCommand}from"@stacksjs/cli";import{app,ui}from"@stacksjs/config";import{err,handleError}from"@stacksjs/error-handling";import{frameworkPath,projectPath}from"@stacksjs/path";import{fs,readJsonFile,readPackageJson,readTextFile,writeTextFile}from"@stacksjs/storage";export async function packageManager(){const{packageManager}=await readPackageJson(frameworkPath("package.json"));return packageManager??""}export async function ensureProjectIsInitialized(){if(!isStacksProject()){console.error("This command must be run inside a Stacks project; create one with: panx buddy new my-app");process.exit(1)}if(await isAppKeySet())return!0;if(fs.existsSync(projectPath(".env")))return!1;if(fs.existsSync(projectPath(".env.example")))fs.copyFileSync(projectPath(".env.example"),projectPath(".env"));else console.error("no .env.example file found");return await isAppKeySet()}export function isStacksProject(){if(!fs.existsSync(projectPath("package.json")))return!1;return fs.existsSync(projectPath("config"))||fs.existsSync(projectPath("storage/framework/core"))}export async function installIfVersionMismatch(){}export async function frameworkVersion(){return(await readPackageJson(frameworkPath("package.json"))).version??""}export async function isAppKeySet(){if(String(process.env.APP_KEY??"").trim().length>16)return!0;try{const appKey=(await readTextFile(".env",projectPath())).data.split(`
2
- `).find((line)=>line.startsWith("APP_KEY="));return!!(appKey&&appKey.length>16)}catch{return!1}}export function determineResetPreset(preset){if(preset===void 0&&ui.reset)preset=ui.reset;if(preset===null)return[];const resetImport={tailwind:'import { tailwindPreflight as reset } from "@cwcss/crosswind"',preflight:'import { tailwindPreflight as reset } from "@cwcss/crosswind"',forms:'import { tailwindFormsPreflight as reset } from "@cwcss/crosswind"'}[preset??"tailwind"];return resetImport?[resetImport]:[]}export function isManifest(obj){if(!obj||typeof obj!=="object")return!1;const candidate=obj;return isOptionalString(candidate.name)&&isOptionalString(candidate.version)&&isOptionalString(candidate.description)}export function isOptionalString(value){const type=typeof value;return value===null||type==="undefined"||type==="string"}export async function setEnvValue(key,value){const file=await readTextFile(projectPath(".env")),escapedKey=key.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),keyPattern=new RegExp(`^${escapedKey}=.*$`,"m"),nextValue=`${key}=${value}`,data=keyPattern.test(file.data)?file.data.replace(keyPattern,nextValue):`${file.data}${file.data.endsWith(`
2
+ `).find((line)=>line.startsWith("APP_KEY="));return!!(appKey&&appKey.length>16)}catch{return!1}}export function determineResetPreset(preset){if(preset===void 0&&ui.reset)preset=ui.reset;if(preset===null)return[];const resetImport={tailwind:'import { tailwindPreflight as reset } from "@stacksjs/ts-css/engine"',preflight:'import { tailwindPreflight as reset } from "@stacksjs/ts-css/engine"',forms:'import { tailwindFormsPreflight as reset } from "@stacksjs/ts-css/engine"'}[preset??"tailwind"];return resetImport?[resetImport]:[]}export function isManifest(obj){if(!obj||typeof obj!=="object")return!1;const candidate=obj;return isOptionalString(candidate.name)&&isOptionalString(candidate.version)&&isOptionalString(candidate.description)}export function isOptionalString(value){const type=typeof value;return value===null||type==="undefined"||type==="string"}export async function setEnvValue(key,value){const file=await readTextFile(projectPath(".env")),escapedKey=key.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),keyPattern=new RegExp(`^${escapedKey}=.*$`,"m"),nextValue=`${key}=${value}`,data=keyPattern.test(file.data)?file.data.replace(keyPattern,nextValue):`${file.data}${file.data.endsWith(`
3
3
  `)?"":`
4
4
  `}${nextValue}
5
5
  `;await writeTextFile({path:projectPath(".env"),data})}export async function runNpmScript(script,options){const{data:manifest}=await readJsonFile("package.json",frameworkPath());if(isManifest(manifest)&&hasScript(manifest,script))return await runCommand(`bun run ${script}`,options);return err(handleError(`The ${script} script does not exist in the package.json file.`))}export function hasScript(manifest,script){const scripts=manifest.scripts;if(scripts&&typeof scripts==="object")return Boolean(scripts[script]);return!1}export function parseYaml(content){return Bun.YAML.parse(content)}export function determineDebugLevel(options){if(options?.verbose===!0)return!0;return app.debug===!0}export function isIpv6(address){return address.family==="IPv6"||address.family===6}export function dumpYaml(content){const yaml=Bun.YAML;if(typeof yaml.stringify==="function")return yaml.stringify(content);return JSON.stringify(content,null,2)}export function loadYaml(content){return Bun.YAML.parse(content)}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/utils",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.220",
5
+ "version": "0.75.222",
6
6
  "description": "The Stacks helper functions.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -62,20 +62,20 @@
62
62
  "size": "bun scripts/export-size.ts"
63
63
  },
64
64
  "dependencies": {
65
- "@stacksjs/browser": "0.75.220",
66
- "@stacksjs/cli": "0.75.220",
67
- "@stacksjs/config": "0.75.220",
68
- "@stacksjs/enums": "0.75.220",
69
- "@stacksjs/error-handling": "0.75.220",
70
- "@stacksjs/logging": "0.75.220",
71
- "@stacksjs/path": "0.75.220",
72
- "@stacksjs/storage": "0.75.220",
73
- "@stacksjs/strings": "0.75.220",
74
- "@stacksjs/types": "0.75.220"
65
+ "@stacksjs/browser": "0.75.222",
66
+ "@stacksjs/cli": "0.75.222",
67
+ "@stacksjs/config": "0.75.222",
68
+ "@stacksjs/enums": "0.75.222",
69
+ "@stacksjs/error-handling": "0.75.222",
70
+ "@stacksjs/logging": "0.75.222",
71
+ "@stacksjs/path": "0.75.222",
72
+ "@stacksjs/storage": "0.75.222",
73
+ "@stacksjs/strings": "0.75.222",
74
+ "@stacksjs/types": "0.75.222"
75
75
  },
76
76
  "devDependencies": {
77
- "@stacksjs/arrays": "0.75.220",
78
- "@stacksjs/lint": "0.75.220",
77
+ "@stacksjs/arrays": "0.75.222",
78
+ "@stacksjs/lint": "0.75.222",
79
79
  "better-dx": "^0.2.24",
80
80
  "filesize": "^11.0.25",
81
81
  "markdown-table": "^3.0.4"