@storm-stack/file-system
Advanced tools
Comparing version 1.17.1 to 1.17.2
@@ -0,46 +1,73 @@ | ||
## 1.17.2 (2024-01-29) | ||
### 🩹 Fixes | ||
- **plugin-system:** Resolved various linting issues with workspace ([71d1541](https://github.com/storm-software/storm-stack/commit/71d1541)) | ||
### ❤️ Thank You | ||
- Patrick Sullivan | ||
## 1.17.1 (2024-01-29) | ||
### 🩹 Fixes | ||
- **plugin-system:** Resolved issue with instanciating the `PluginLoader` from the provided module ([778bb6d](https://github.com/storm-software/storm-stack/commit/778bb6d)) | ||
- **plugin-system:** Resolved issue with instanciating the `PluginLoader` from the provided module ([778bb6d](https://github.com/storm-software/storm-stack/commit/778bb6d)) | ||
### ❤️ Thank You | ||
- Patrick Sullivan | ||
### ❤️ Thank You | ||
- Patrick Sullivan | ||
## 1.17.0 (2024-01-24) | ||
### 🚀 Features | ||
- **plugin-system:** Added the `autoInstall` option to resolvers ([18c1841](https://github.com/storm-software/storm-stack/commit/18c1841)) | ||
- **plugin-system:** Added the `autoInstall` option to resolvers ([18c1841](https://github.com/storm-software/storm-stack/commit/18c1841)) | ||
### ❤️ Thank You | ||
- Patrick Sullivan | ||
### ❤️ Thank You | ||
- Patrick Sullivan | ||
## 1.16.7 (2024-01-24) | ||
### 🩹 Fixes | ||
- **plugin-system:** Added tsconfig file paths to resolver handler ([56ff717](https://github.com/storm-software/storm-stack/commit/56ff717)) | ||
- **plugin-system:** Added tsconfig file paths to resolver handler ([56ff717](https://github.com/storm-software/storm-stack/commit/56ff717)) | ||
### ❤️ Thank You | ||
- Patrick Sullivan | ||
### ❤️ Thank You | ||
- Patrick Sullivan | ||
## 1.16.3 (2024-01-21) | ||
### 🩹 Fixes | ||
- **monorepo:** Update the storm-ops workspace dependencies ([faadeb6](https://github.com/storm-software/storm-stack/commit/faadeb6)) | ||
- **monorepo:** Update the storm-ops workspace dependencies ([faadeb6](https://github.com/storm-software/storm-stack/commit/faadeb6)) | ||
### ❤️ Thank You | ||
- Patrick Sullivan | ||
### ❤️ Thank You | ||
- Patrick Sullivan | ||
## [1.16.2](https://github.com/storm-software/storm-stack/compare/file-system-v1.16.1...file-system-v1.16.2) (2024-01-21) | ||
### Bug Fixes | ||
- **plugin-system:** Resolved build issues ([e790271](https://github.com/storm-software/storm-stack/commit/e790271a9fa23375486a6f348e1cc1665a4a8361)) | ||
* **plugin-system:** Resolved build issues ([e790271](https://github.com/storm-software/storm-stack/commit/e790271a9fa23375486a6f348e1cc1665a4a8361)) | ||
@@ -47,0 +74,0 @@ ## [1.16.1](https://github.com/storm-software/storm-stack/compare/file-system-v1.16.0...file-system-v1.16.1) (2024-01-21) |
{ | ||
"name": "@storm-stack/file-system", | ||
"version": "1.17.1", | ||
"version": "1.17.2", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "⚡ The storm-stack monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.", |
@@ -0,4 +1,4 @@ | ||
import { constants, type CopySyncOptions, copyFileSync, cpSync } from "node:fs"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { StormLog } from "@storm-stack/logging"; | ||
import fs, { CopySyncOptions, copyFileSync, cpSync } from "node:fs"; | ||
@@ -16,3 +16,3 @@ /** | ||
to: string, | ||
options?: CopySyncOptions | ||
options?: CopySyncOptions, | ||
): string | Buffer | undefined => { | ||
@@ -25,3 +25,3 @@ try { | ||
} catch (e) { | ||
StormLog.error(`An error occurred copying files`); | ||
StormLog.error("An error occurred copying files"); | ||
StormLog.error(e); | ||
@@ -44,3 +44,3 @@ | ||
file: string, | ||
dest: string | ||
dest: string, | ||
): string | Buffer | undefined => { | ||
@@ -50,7 +50,7 @@ try { | ||
copyFileSync(file, dest, fs.constants.COPYFILE_FICLONE); | ||
copyFileSync(file, dest, constants.COPYFILE_FICLONE); | ||
return undefined; | ||
} catch (e) { | ||
StormLog.error(`An error occurred copying files`); | ||
StormLog.error("An error occurred copying files"); | ||
StormLog.error(e); | ||
@@ -57,0 +57,0 @@ |
@@ -0,3 +1,3 @@ | ||
import { dirname, isAbsolute, parse, relative, sep } from "node:path"; | ||
import { EMPTY_STRING } from "@storm-stack/utilities"; | ||
import { dirname, isAbsolute, parse, relative, sep } from "node:path"; | ||
import { getWorkspaceRoot } from "./get-workspace-root"; | ||
@@ -16,3 +16,3 @@ import { joinPaths } from "./join-paths"; | ||
?.split( | ||
filePath?.includes(sep) ? sep : filePath?.includes("/") ? "/" : "\\" | ||
filePath?.includes(sep) ? sep : filePath?.includes("/") ? "/" : "\\", | ||
) | ||
@@ -97,11 +97,11 @@ ?.pop() ?? "" | ||
filePath: string, | ||
basePath: string = getWorkspaceRoot() | ||
basePath: string = getWorkspaceRoot(), | ||
) { | ||
if (isAbsolute(filePath)) { | ||
return filePath; | ||
} else if (basePath) { | ||
} | ||
if (basePath) { | ||
return joinPaths(dirname(basePath), filePath); | ||
} else { | ||
return joinPaths(process.cwd(), filePath); | ||
} | ||
return joinPaths(process.cwd(), filePath); | ||
} | ||
@@ -131,4 +131,4 @@ | ||
file.dir, | ||
newFileName.includes(".") ? newFileName : newFileName + file.ext | ||
newFileName.includes(".") ? newFileName : newFileName + file.ext, | ||
); | ||
} |
@@ -12,9 +12,9 @@ import { createStormConfig } from "@storm-software/config-tools"; | ||
return config.workspaceRoot; | ||
} else { | ||
const root = findWorkspaceRoot(process.cwd()); | ||
process.env.STORM_WORKSPACE_ROOT = root?.dir; | ||
process.env.NX_WORKSPACE_ROOT_PATH ??= root?.dir; | ||
} | ||
return root?.dir; | ||
} | ||
const root = findWorkspaceRoot(process.cwd()); | ||
process.env.STORM_WORKSPACE_ROOT = root?.dir; | ||
process.env.NX_WORKSPACE_ROOT_PATH ??= root?.dir; | ||
return root?.dir; | ||
} | ||
@@ -21,0 +21,0 @@ |
@@ -12,5 +12,5 @@ import { lstatSync } from "node:fs"; | ||
export const isFile = (path: string, additionalPath?: string): boolean => { | ||
return !!lstatSync( | ||
additionalPath ? joinPaths(additionalPath, path) : path, | ||
)?.isFile(); | ||
return !!lstatSync( | ||
additionalPath ? joinPaths(additionalPath, path) : path, | ||
)?.isFile(); | ||
}; | ||
@@ -26,5 +26,5 @@ | ||
export const isDirectory = (path: string, additionalPath?: string): boolean => { | ||
return !!lstatSync( | ||
additionalPath ? joinPaths(additionalPath, path) : path, | ||
).isDirectory(); | ||
return !!lstatSync( | ||
additionalPath ? joinPaths(additionalPath, path) : path, | ||
).isDirectory(); | ||
}; |
@@ -0,4 +1,4 @@ | ||
import { readFile as readFileFs, readFileSync } from "node:fs"; | ||
import { promisify } from "node:util"; | ||
import { StormError } from "@storm-stack/errors"; | ||
import { readFile as readFileFs, readFileSync } from "fs"; | ||
import { promisify } from "node:util"; | ||
import { FileSystemErrorCode } from "../errors"; | ||
@@ -15,3 +15,3 @@ | ||
throw new StormError(FileSystemErrorCode.invalid_file_path, { | ||
message: "No file path provided to read data" | ||
message: "No file path provided to read data", | ||
}); | ||
@@ -24,3 +24,3 @@ } | ||
message: "An error occurred writing data to file", | ||
cause: e | ||
cause: e, | ||
}); | ||
@@ -35,7 +35,7 @@ } | ||
*/ | ||
export const readFileAsync = async (filePath: string): Promise<string> => { | ||
export const readFileAsync = (filePath: string): Promise<string> => { | ||
try { | ||
if (!filePath) { | ||
throw new StormError(FileSystemErrorCode.invalid_file_path, { | ||
message: "No file path provided to read data" | ||
message: "No file path provided to read data", | ||
}); | ||
@@ -48,5 +48,5 @@ } | ||
message: "An error occurred writing data to file", | ||
cause: e | ||
cause: e, | ||
}); | ||
} | ||
}; |
@@ -0,5 +1,5 @@ | ||
import { writeFile as writeFileFs, writeFileSync } from "node:fs"; | ||
import { promisify } from "node:util"; | ||
import { StormError } from "@storm-stack/errors"; | ||
import { StormParser } from "@storm-stack/serialization"; | ||
import { writeFile as writeFileFs, writeFileSync } from "fs"; | ||
import { promisify } from "node:util"; | ||
import { FileSystemErrorCode } from "../errors"; | ||
@@ -17,7 +17,8 @@ | ||
throw new StormError(FileSystemErrorCode.invalid_file_path, { | ||
message: "No file path provided to write data" | ||
message: "No file path provided to write data", | ||
}); | ||
} else if (!content) { | ||
} | ||
if (!content) { | ||
throw new StormError(FileSystemErrorCode.invalid_file_content, { | ||
message: "No content provided to write to file" | ||
message: "No content provided to write to file", | ||
}); | ||
@@ -30,3 +31,3 @@ } | ||
message: "An error occurred writing data to file", | ||
cause: e | ||
cause: e, | ||
}); | ||
@@ -41,5 +42,5 @@ } | ||
*/ | ||
export const writeFileAsync = async ( | ||
export const writeFileAsync = ( | ||
filePath: string, | ||
content: any | ||
content: any, | ||
): Promise<void> => { | ||
@@ -49,3 +50,3 @@ try { | ||
throw new StormError(FileSystemErrorCode.invalid_file_path, { | ||
message: "No file path provided to read data" | ||
message: "No file path provided to read data", | ||
}); | ||
@@ -58,5 +59,5 @@ } | ||
message: "An error occurred writing data to file", | ||
cause: e | ||
cause: e, | ||
}); | ||
} | ||
}; |
@@ -5,3 +5,3 @@ import fs from "node:fs"; | ||
import { EMPTY_STRING } from "@storm-stack/utilities"; | ||
import { findFileName, findFilePath } from ".."; | ||
import { findFileName, findFilePath } from "../files/file-path-fns"; | ||
@@ -27,7 +27,7 @@ const singleComment = Symbol("singleComment"); | ||
jsonString: string, | ||
{ whitespace = true, trailingCommas = false } = {} | ||
{ whitespace = true, trailingCommas = false } = {}, | ||
) => { | ||
if (typeof jsonString !== "string") { | ||
throw new TypeError( | ||
`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\`` | ||
`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``, | ||
); | ||
@@ -55,3 +55,6 @@ } | ||
} | ||
if (!isInsideComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "//") { | ||
if ( | ||
!isInsideComment && | ||
currentCharacter + (nextCharacter ?? EMPTY_STRING) === "//" | ||
) { | ||
buffer += jsonString.slice(offset, index); | ||
@@ -73,3 +76,6 @@ offset = index; | ||
offset = index; | ||
} else if (!isInsideComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "/*") { | ||
} else if ( | ||
!isInsideComment && | ||
currentCharacter + (nextCharacter ?? EMPTY_STRING) === "/*" | ||
) { | ||
buffer += jsonString.slice(offset, index); | ||
@@ -114,3 +120,7 @@ offset = index; | ||
return ( | ||
result + buffer + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset)) | ||
result + | ||
buffer + | ||
(isInsideComment | ||
? strip(jsonString.slice(offset)) | ||
: jsonString.slice(offset)) | ||
); | ||
@@ -128,3 +138,7 @@ }; | ||
const req = createRequire(import.meta.url); | ||
const findUp = (name: string, startDir: string, stopDir = path.parse(startDir).root) => { | ||
const findUp = ( | ||
name: string, | ||
startDir: string, | ||
stopDir = path.parse(startDir).root, | ||
) => { | ||
let dir = startDir; | ||
@@ -144,3 +158,4 @@ while (dir !== stopDir) { | ||
const resolveTsConfigFromFile = (cwd: string, filename: string) => { | ||
if (path.isAbsolute(filename)) return fs.existsSync(filename) ? filename : null; | ||
if (path.isAbsolute(filename)) | ||
return fs.existsSync(filename) ? filename : null; | ||
return findUp(filename, cwd); | ||
@@ -156,3 +171,7 @@ }; | ||
const loadTsConfigInternal = (_dir = process.cwd(), name = "tsconfig.json", isExtends = false) => { | ||
const loadTsConfigInternal = ( | ||
_dir = process.cwd(), | ||
name = "tsconfig.json", | ||
isExtends = false, | ||
) => { | ||
let _a: any; | ||
@@ -162,3 +181,5 @@ let _b: any; | ||
const dir = path.resolve(_dir); | ||
const id = isExtends ? resolveTsConfigFromExtends(dir, name) : resolveTsConfigFromFile(dir, name); | ||
const id = isExtends | ||
? resolveTsConfigFromExtends(dir, name) | ||
: resolveTsConfigFromFile(dir, name); | ||
@@ -173,7 +194,12 @@ if (!id) { | ||
if ((_a = data.compilerOptions) == null ? void 0 : _a.baseUrl) { | ||
data.compilerOptions.baseUrl = path.join(configDir, data.compilerOptions.baseUrl); | ||
data.compilerOptions.baseUrl = path.join( | ||
configDir, | ||
data.compilerOptions.baseUrl, | ||
); | ||
} | ||
const extendsFiles = []; | ||
if (data.extends) { | ||
const extendsList = Array.isArray(data.extends) ? data.extends : [data.extends]; | ||
const extendsList = Array.isArray(data.extends) | ||
? data.extends | ||
: [data.extends]; | ||
const extendsData: any = {}; | ||
@@ -190,4 +216,4 @@ for (const name2 of extendsList) { | ||
? void 0 | ||
: _b.compilerOptions) | ||
} | ||
: _b.compilerOptions), | ||
}, | ||
}); | ||
@@ -202,4 +228,4 @@ extendsFiles.push(...parentConfig.files); | ||
...extendsData.compilerOptions, | ||
...data.compilerOptions | ||
} | ||
...data.compilerOptions, | ||
}, | ||
}); | ||
@@ -206,0 +232,0 @@ } |
@@ -0,3 +1,3 @@ | ||
import { basename, resolve } from "node:path"; | ||
import { execute } from "@storm-stack/cli"; | ||
import { basename, resolve } from "path"; | ||
import { exists } from "../files/exists"; | ||
@@ -11,3 +11,3 @@ import { joinPaths } from "../files/join-paths"; | ||
PNPM: "pnpm" as PackageManagers, | ||
BUN: "bun" as PackageManagers | ||
BUN: "bun" as PackageManagers, | ||
}; | ||
@@ -19,3 +19,3 @@ | ||
while (true) { | ||
const target = names.find(name => exists(joinPaths(dir, name))); | ||
const target = names.find((name) => exists(joinPaths(dir, name))); | ||
if (target) return target; | ||
@@ -32,3 +32,3 @@ | ||
["yarn.lock", "pnpm-lock.yaml", "package-lock.json", "bun.lockb"], | ||
projectPath | ||
projectPath, | ||
); | ||
@@ -59,3 +59,3 @@ | ||
projectPath = ".", | ||
exactVersion = true | ||
exactVersion = true, | ||
) { | ||
@@ -67,5 +67,5 @@ const manager = pkgManager ?? getPackageManager(projectPath); | ||
execute( | ||
`yarn --cwd "${projectPath}" add ${ | ||
exactVersion ? "--exact" : "" | ||
} ${pkg}@${tag} ${dev ? " --dev" : ""}` | ||
`yarn --cwd "${projectPath}" add ${exactVersion ? "--exact" : ""} ${pkg}@${tag} ${ | ||
dev ? " --dev" : "" | ||
}`, | ||
); | ||
@@ -78,3 +78,3 @@ break; | ||
dev ? " --save-dev" : "" | ||
} ${pkg}@${tag}` | ||
} ${pkg}@${tag}`, | ||
); | ||
@@ -85,8 +85,6 @@ break; | ||
execute( | ||
`bun add ${exactVersion ? "--exact" : ""} ${ | ||
dev ? " --dev" : "" | ||
} ${pkg}@${tag}`, | ||
`bun add ${exactVersion ? "--exact" : ""} ${dev ? " --dev" : ""} ${pkg}@${tag}`, | ||
{ | ||
cwd: projectPath | ||
} | ||
cwd: projectPath, | ||
}, | ||
); | ||
@@ -97,5 +95,5 @@ break; | ||
execute( | ||
`npm install --prefix "${projectPath}" ${ | ||
exactVersion ? "--save-exact" : "" | ||
} ${dev ? " --save-dev" : ""} ${pkg}@${tag}` | ||
`npm install --prefix "${projectPath}" ${exactVersion ? "--save-exact" : ""} ${ | ||
dev ? " --save-dev" : "" | ||
} ${pkg}@${tag}`, | ||
); | ||
@@ -112,3 +110,3 @@ break; | ||
projectPath = ".", | ||
exactVersion = false | ||
exactVersion = false, | ||
) { | ||
@@ -118,5 +116,5 @@ const resolvePath = resolve(projectPath); | ||
require.resolve(pkg, { paths: [resolvePath] }); | ||
} catch (err) { | ||
} catch (_err) { | ||
installPackage(pkg, dev, pkgManager, tag, resolvePath, exactVersion); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { RELEASE_TYPES, ReleaseType, inc, parse, valid } from "semver"; | ||
import { RELEASE_TYPES, type ReleaseType, inc, parse, valid } from "semver"; | ||
@@ -12,7 +12,7 @@ export const parseVersion = (semver: string) => parse(semver); | ||
semverSpecifier: string, | ||
preid?: string | ||
preid?: string, | ||
) => { | ||
if (!valid(currentSemverVersion)) { | ||
throw new Error( | ||
`Invalid semver version "${currentSemverVersion}" provided.` | ||
`Invalid semver version "${currentSemverVersion}" provided.`, | ||
); | ||
@@ -27,3 +27,3 @@ } | ||
throw new Error( | ||
`Unable to derive new version from current version "${currentSemverVersion}" and version specifier "${semverSpecifier}"` | ||
`Unable to derive new version from current version "${currentSemverVersion}" and version specifier "${semverSpecifier}"`, | ||
); | ||
@@ -36,3 +36,3 @@ } | ||
throw new Error( | ||
`Invalid semver version specifier "${semverSpecifier}" provided. Please provide either a valid semver version or a valid semver version keyword.` | ||
`Invalid semver version specifier "${semverSpecifier}" provided. Please provide either a valid semver version or a valid semver version keyword.`, | ||
); | ||
@@ -39,0 +39,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"outDir": "../../dist/out-tsc", | ||
"noEmit": true, | ||
"noEmit": true | ||
}, | ||
@@ -15,6 +15,6 @@ "files": [], | ||
"../cli/src/utilities/is-ci.ts", | ||
"../cli/src/utilities/is-interactive.ts", | ||
"../cli/src/utilities/is-interactive.ts" | ||
], | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"], | ||
"composite": true, | ||
"composite": true | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
64123
861
0