@stacksjs/utils 0.52.9 → 0.53.1

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/guards.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  * @category Guards
5
5
  * @example array.filter(notNullish)
6
6
  */
7
+ export declare function notNullish<T>(v: T | null | undefined): v is NonNullable<T>;
7
8
  /**
8
9
  * Type guard to filter out null values
9
10
  *
package/dist/guards.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ export function notNullish(v) {
2
+ return v != null;
3
+ }
1
4
  export function noNull(v) {
2
5
  return v !== null;
3
6
  }
package/dist/helpers.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { CliOptions, CommandResult, Manifest, NpmScript } from '@stacksjs/types';
2
2
  import detectIndent from 'detect-indent';
3
3
  export declare function isProjectCreated(): Promise<boolean>;
4
+ export declare function installIfVersionMismatch(): Promise<void>;
4
5
  export declare function frameworkVersion(): Promise<string>;
5
6
  export declare function isAppKeySet(): Promise<boolean>;
6
7
  /**
package/dist/helpers.mjs CHANGED
@@ -1,9 +1,10 @@
1
1
  import detectIndent from "detect-indent";
2
2
  import { frameworkPath, projectPath } from "@stacksjs/path";
3
3
  import { parse } from "yaml";
4
- import { log, runCommand, spawn } from "@stacksjs/cli";
5
- import storage from "@stacksjs/storage";
4
+ import { execSync, log, runCommand, spawn } from "@stacksjs/cli";
6
5
  import { app, ui } from "@stacksjs/config";
6
+ import { storage } from "@stacksjs/storage";
7
+ import { semver } from "./versions.mjs";
7
8
  export async function isProjectCreated() {
8
9
  if (storage.isFile(".env"))
9
10
  return await isAppKeySet();
@@ -11,17 +12,30 @@ export async function isProjectCreated() {
11
12
  await spawn("cp .env.example .env", { stdio: "inherit", cwd: projectPath() });
12
13
  return await isAppKeySet();
13
14
  }
15
+ export async function installIfVersionMismatch() {
16
+ const dependenciesYaml = storage.fs.readFileSync(projectPath("tea.yaml"), "utf8");
17
+ const dependencies = parseYaml(dependenciesYaml).dependencies;
18
+ const requiredNodeVersion = dependencies["nodejs.org"];
19
+ const requiredPnpmVersion = dependencies["pnpm.io"];
20
+ const installedNodeVersion = process.version;
21
+ const installedPnpmVersion = execSync("pnpm -v").trim();
22
+ if (!semver.satisfies(installedNodeVersion, requiredNodeVersion)) {
23
+ log.error(`Installed Node.js version (${installedNodeVersion}) does not satisfy required version (${requiredNodeVersion}). One moment...`);
24
+ await runCommand(`tea +nodejs.org${requiredNodeVersion} >/dev/null 2>&1`);
25
+ }
26
+ if (!semver.satisfies(installedPnpmVersion, requiredPnpmVersion)) {
27
+ log.error(`Installed pnpm version (${installedPnpmVersion}) does not satisfy required version (${requiredPnpmVersion}). One moment...`);
28
+ await runCommand(`tea +pnpm.io${requiredPnpmVersion} >/dev/null 2>&1`);
29
+ }
30
+ }
14
31
  export async function frameworkVersion() {
15
- const packageJson = await storage.fs.readJson(frameworkPath("package.json"));
16
- return packageJson.version;
32
+ return (await storage.readPackageJson(frameworkPath("package.json"))).version;
17
33
  }
18
34
  export async function isAppKeySet() {
19
35
  const env = await storage.readTextFile(".env", projectPath());
20
36
  const lines = env.data.split("\n");
21
37
  const appKey = lines.find((line) => line.startsWith("APP_KEY="));
22
- if (appKey && appKey.length > 16)
23
- return true;
24
- return false;
38
+ return !!(appKey && appKey.length > 16);
25
39
  }
26
40
  export function determineResetPreset(preset) {
27
41
  if (ui.reset)
package/dist/vendors.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { asyncComputed, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsMasterCss, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, cloneFnJSON, computedAsync, computedInject, createFetch, createReusableTemplate, createTemplatePromise, createUnrefFn, customStorageEventName, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, executeTransition, formatTimeAgo, getSSRHandler, mapGamepadToXbox360Controller, onClickOutside, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, setSSRHandler, templateRef, unrefElement, useActiveElement, useAnimate, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, useCloned, useColorMode, useConfirmDialog, useCssVar, useCurrentElement, useCycleList, useDark, useDebouncedRefHistory, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDisplayMedia, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementHover, useElementSize, useElementVisibility, useEventBus, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetch, useFileDialog, useFileSystemAccess, useFocus, useFocusWithin, useFps, useFullscreen, useGamepad, useGeolocation, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useKeyModifier, useLocalStorage, useMagicKeys, useManualRefHistory, useMediaControls, useMediaQuery, useMemoize, useMemory, useMounted, useMouse, useMouseInElement, useMousePressed, useMutationObserver, useNavigatorLanguage, useNetwork, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, useParallax, useParentElement, usePerformanceObserver, usePermission, usePointer, usePointerLock, usePointerSwipe, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePrevious, useRafFn, useRefHistory, useResizeObserver, useScreenOrientation, useScreenSafeArea, useScriptTag, useScroll, useScrollLock, useSessionStorage, useShare, useSorted, useSpeechRecognition, useSpeechSynthesis, useStepper, useStorage, useStorageAsync, useStyleTag, useSupported, useSwipe, useTemplateRefsList, useTextDirection, useTextSelection, useTextareaAutosize, useThrottledRefHistory, useTimeAgo, useTimeoutPoll, useTimestamp, useTitle, useTransition, useUrlSearchParams, useUserMedia, useVModel, useVModels, useVibrate, useVirtualList, useWakeLock, useWebNotification, useWebSocket, useWebWorker, useWebWorkerFn, useWindowFocus, useWindowScroll, useWindowSize, useDateFormat, useNow, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever, syncRef, syncRefs, throttledRef, throttledWatch, toReactive, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, isDefined, ignorableWatch, extendRef, eagerComputed, debouncedRef, debouncedWatch, createReactiveFn, createSharedComposable, createInjectionState, createGlobalState, createEventHook, controlledRef, controlledComputed, computedEager, computedWithControl, autoResetRef, } from '@vueuse/core';
1
+ export { asyncComputed, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsMasterCss, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, cloneFnJSON, computedAsync, computedInject, createFetch, createReusableTemplate, createTemplatePromise, createUnrefFn, customStorageEventName, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, executeTransition, formatTimeAgo, getSSRHandler, mapGamepadToXbox360Controller, onClickOutside, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, setSSRHandler, templateRef, unrefElement, useActiveElement, useAnimate, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, useCloned, useColorMode, useConfirmDialog, useCssVar, useCurrentElement, useCycleList, useDark, useDebouncedRefHistory, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDisplayMedia, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementHover, useElementSize, useElementVisibility, useEventBus, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetch, useFileDialog, useFileSystemAccess, useFocus, useFocusWithin, useFps, useFullscreen, useGamepad, useGeolocation, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useKeyModifier, useLocalStorage, useMagicKeys, useManualRefHistory, useMediaControls, useMediaQuery, useMemoize, useMemory, useMounted, useMouse, useMouseInElement, useMousePressed, useMutationObserver, useNavigatorLanguage, useNetwork, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, useParallax, useParentElement, usePerformanceObserver, usePermission, usePointer, usePointerLock, usePointerSwipe, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePrevious, useRafFn, useRefHistory, useResizeObserver, useScreenOrientation, useScreenSafeArea, useScriptTag, useScroll, useScrollLock, useSessionStorage, useShare, useSorted, useSpeechRecognition, useSpeechSynthesis, useStepper, useStorage, useStorageAsync, useStyleTag, useSupported, useSwipe, useTemplateRefsList, useTextDirection, useTextSelection, useTextareaAutosize, useThrottledRefHistory, useTimeAgo, useTimeoutPoll, useTimestamp, useTitle, useTransition, useToggle, useUrlSearchParams, useUserMedia, useVModel, useVModels, useVibrate, useVirtualList, useWakeLock, useWebNotification, useWebSocket, useWebWorker, useWebWorkerFn, useWindowFocus, useWindowScroll, useWindowSize, useDateFormat, useNow, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever, syncRef, syncRefs, throttledRef, throttledWatch, toReactive, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, isDefined, ignorableWatch, extendRef, eagerComputed, debouncedRef, debouncedWatch, createReactiveFn, createSharedComposable, createInjectionState, createGlobalState, createEventHook, controlledRef, controlledComputed, computedEager, computedWithControl, autoResetRef, } from '@vueuse/core';
2
2
  export type { HeadClient, HeadObject, HeadObjectPlain, HookBeforeDomUpdate, HookEntriesResolved, HookTagsResolved, LegacyHeadOptions, } from '@vueuse/head';
3
3
  export { Head, HeadVuePlugin, createHead, renderHeadToString, } from '@vueuse/head';
package/dist/vendors.mjs CHANGED
@@ -145,6 +145,7 @@ export {
145
145
  useTimestamp,
146
146
  useTitle,
147
147
  useTransition,
148
+ useToggle,
148
149
  useUrlSearchParams,
149
150
  useUserMedia,
150
151
  useVModel,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/utils",
3
3
  "type": "module",
4
- "version": "0.52.9",
4
+ "version": "0.53.1",
5
5
  "packageManager": "pnpm@8.5.1",
6
6
  "description": "The Stacks helper functions.",
7
7
  "author": "Chris Breuer",
@@ -56,15 +56,15 @@
56
56
  "p-limit": "^4.0.0",
57
57
  "rimraf": "^5.0.1",
58
58
  "semver": "^7.5.1",
59
- "yaml": "^2.2.2",
60
- "@stacksjs/arrays": "0.52.9",
61
- "@stacksjs/cli": "0.52.9",
62
- "@stacksjs/config": "0.52.9",
63
- "@stacksjs/development": "0.52.9",
64
- "@stacksjs/lint": "0.52.9",
65
- "@stacksjs/path": "0.52.9",
66
- "@stacksjs/storage": "0.52.9",
67
- "@stacksjs/types": "0.52.9"
59
+ "yaml": "^2.3.0",
60
+ "@stacksjs/arrays": "0.53.1",
61
+ "@stacksjs/cli": "0.53.1",
62
+ "@stacksjs/config": "0.53.1",
63
+ "@stacksjs/development": "0.53.1",
64
+ "@stacksjs/lint": "0.53.1",
65
+ "@stacksjs/path": "0.53.1",
66
+ "@stacksjs/storage": "0.53.1",
67
+ "@stacksjs/types": "0.53.1"
68
68
  },
69
69
  "dependencies": {
70
70
  "@vueuse/core": "^10.1.2",
@@ -81,17 +81,17 @@
81
81
  "perfect-debounce": "^1.0.0",
82
82
  "rimraf": "^5.0.1",
83
83
  "semver": "^7.5.1",
84
- "yaml": "^2.2.2",
85
- "@stacksjs/cli": "0.52.9",
86
- "@stacksjs/config": "0.52.9",
87
- "@stacksjs/arrays": "0.52.9",
88
- "@stacksjs/lint": "0.52.9",
89
- "@stacksjs/path": "0.52.9",
90
- "@stacksjs/storage": "0.52.9",
91
- "@stacksjs/types": "0.52.9"
84
+ "yaml": "^2.3.0",
85
+ "@stacksjs/arrays": "0.53.1",
86
+ "@stacksjs/cli": "0.53.1",
87
+ "@stacksjs/config": "0.53.1",
88
+ "@stacksjs/lint": "0.53.1",
89
+ "@stacksjs/path": "0.53.1",
90
+ "@stacksjs/storage": "0.53.1",
91
+ "@stacksjs/types": "0.53.1"
92
92
  },
93
93
  "devDependencies": {
94
- "@stacksjs/development": "0.52.9"
94
+ "@stacksjs/development": "0.53.1"
95
95
  },
96
96
  "scripts": {
97
97
  "build": "unbuild",