@stacksjs/utils 0.72.20 → 0.72.22
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.js +1 -1
- package/package.json +11 -11
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import process from"node:process";import{runAction}from"@stacksjs/actions";import{log,runCommand}from"@stacksjs/cli";import{app,ui}from"@stacksjs/config";import{Action}from"@stacksjs/enums";import{err,handleError,ok}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 initProject(){if(app.env!=="production")log.info("Project not yet initialized, generating application key...");else handleError("Please run `buddy key:generate` to generate an application key");const result=await runAction(Action.KeyGenerate,{cwd:projectPath()});if(result.isErr)return err(handleError(result.error));log.info("Application key generated.");return ok(result.value)}export async function ensureProjectIsInitialized(){if(!isStacksProject()){console.error("This command must be run inside a Stacks project; create one with: panx @stacksjs/buddy new my-app");process.exit(1)}if(fs.existsSync(projectPath(".env")))return
|
|
1
|
+
import process from"node:process";import{runAction}from"@stacksjs/actions";import{log,runCommand}from"@stacksjs/cli";import{app,ui}from"@stacksjs/config";import{Action}from"@stacksjs/enums";import{err,handleError,ok}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 initProject(){if(app.env!=="production")log.info("Project not yet initialized, generating application key...");else handleError("Please run `buddy key:generate` to generate an application key");const result=await runAction(Action.KeyGenerate,{cwd:projectPath()});if(result.isErr)return err(handleError(result.error));log.info("Application key generated.");return ok(result.value)}export async function ensureProjectIsInitialized(){if(!isStacksProject()){console.error("This command must be run inside a Stacks project; create one with: panx @stacksjs/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
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){return obj&&typeof obj==="object"&&isOptionalString(obj.name)&&isOptionalString(obj.version)&&isOptionalString(obj.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}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/utils",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.72.
|
|
5
|
+
"version": "0.72.22",
|
|
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.72.
|
|
65
|
+
"@stacksjs/browser": "0.72.22"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@stacksjs/actions": "0.72.
|
|
69
|
-
"@stacksjs/arrays": "0.72.
|
|
70
|
-
"@stacksjs/cli": "0.72.
|
|
71
|
-
"@stacksjs/config": "0.72.
|
|
68
|
+
"@stacksjs/actions": "0.72.22",
|
|
69
|
+
"@stacksjs/arrays": "0.72.22",
|
|
70
|
+
"@stacksjs/cli": "0.72.22",
|
|
71
|
+
"@stacksjs/config": "0.72.22",
|
|
72
72
|
"better-dx": "^0.2.23",
|
|
73
73
|
"filesize": "^11.0.22",
|
|
74
74
|
"markdown-table": "^3.0.4",
|
|
75
|
-
"@stacksjs/lint": "0.72.
|
|
76
|
-
"@stacksjs/path": "0.72.
|
|
77
|
-
"@stacksjs/storage": "0.72.
|
|
78
|
-
"@stacksjs/strings": "0.72.
|
|
79
|
-
"@stacksjs/types": "0.72.
|
|
75
|
+
"@stacksjs/lint": "0.72.22",
|
|
76
|
+
"@stacksjs/path": "0.72.22",
|
|
77
|
+
"@stacksjs/storage": "0.72.22",
|
|
78
|
+
"@stacksjs/strings": "0.72.22",
|
|
79
|
+
"@stacksjs/types": "0.72.22"
|
|
80
80
|
}
|
|
81
81
|
}
|