README
get-path (OperationClassification cjs)
Useful functions to get paths within King OS.
Depends on sdk-operations, which makes it only work inside of a typerepo.
returns project root folder path
recursive. goes up until it finds a folder that's the project root
if no source path is given, uses the directory name where the function is executed from as a starting point
Input | ||
---|---|---|
fullSourcePath (optional) | string | |
Output | string |
returns project root folder path
recursive. goes up until it finds a folder that's the project root
if no source path is given, uses the directory name where the function is executed from as a starting point
Makes a path relative using proper parsing
Resulting path will apply the paths conventions
- no slash at the end
- no slash at the beginning
Input | ||
---|---|---|
absolutePath | string | absolute path of a file or folder without a slash at the end |
Output | String |
Makes a path relative using proper parsing
Resulting path will apply the paths conventions
- no slash at the end
- no slash at the beginning
Input | ||
---|---|---|
startPath | string | |
Output | string |
Gets a path of any operation in the project
TODO: IDEA: maybe auto-generate key-value JSON where keys are the package-names of all operations and values are paths of their locations in the file system. we can easily generate this ourselves, but maybe it's also easy to use the npm yarn workspace for this, although it may not be available in all circumstances, so better not rely on it. The advantage of this would be that this function becomes sync and is much more efficient. The disadvantage is that every time you move something or add something new, this indexation has to happen, otherwise it fails.
Input | ||
---|---|---|
operationName | string | specify the operation folder name |
Output |
returns an array of all (absolute) paths containing operations
for a bundled project, that means /apps, /packages, /modules
for the OS project, that means /operations/tools and /operations/niches
Input | ||
---|---|---|
config (optional) | { manualProjectRoot?: string, } | |
Output | string[] |
returns an array of all (absolute) paths containing operations
for a bundled project, that means /apps, /packages, /modules
for the OS project, that means /operations/tools and /operations/niches
Gets project path, or a folder in the root that is convention
Input | ||
---|---|---|
- | ||
Output | string |
returns a file id (path without extension) relative to the src folder of an operation
e.g. "general" for src/general.ts
NB: assumes all src is in the src folder
NB: removes "/" in the beginning, if found
Input | ||
---|---|---|
operationRelativePath | string | |
Output |
returns a file id (path without extension) relative to the src folder of an operation
e.g. "general" for src/general.ts
NB: assumes all src is in the src folder
NB: removes "/" in the beginning, if found
Returns OperationClassification if it's an operation, or undefined if it's not
NB: don't confuse this with ImportClassification
Input | ||
---|---|---|
folderPath | string | |
Output |
Input | ||
---|---|---|
folderPath (optional) | string | |
Output | { } |
Returns OperationClassification if it's an operation, or undefined if it's not
NB: don't confuse this with ImportClassification
something like src/xxx/xxx/x.ts (no slash at start)
Input | ||
---|---|---|
absolutePath | string | |
Output |
something like src/xxx/xxx/x.ts (no slash at start)
get all operation-related path information that can be inferred from the path
NB: currently it also looks up the operation name from its packagejson
Input | ||
---|---|---|
absolutePath | string | |
Output |
gets all kinds of information that can be inferred from any path (file or folder).
Input | ||
---|---|---|
absolutePath | string | |
Output | { relativePathFromProjectRoot: string, } |
get all operation-related path information that can be inferred from the path
NB: currently it also looks up the operation name from its packagejson
gets all kinds of information that can be inferred from any path (file or folder).
Input | ||
---|---|---|
- | ||
Output |
returns a relative link between two files
Input | ||
---|---|---|
absoluteFromFilePath | string | |
Output | String |
Checks whether or not an absolute path contains an operation. The only check it's doing is that the folder must contain both a package.json as well as a tsconfig.json
Input | ||
---|---|---|
absoluteFolderPath | string | |
Output | { } |
returns a relative link between two files
Checks whether or not an absolute path contains an operation. The only check it's doing is that the folder must contain both a package.json as well as a tsconfig.json
Show test information(2)
Input | ||
---|---|---|
- | ||
Output |
Show internal (24)
recursive. goes up a folder until it finds a package.json
Input | ||
---|---|---|
- | ||
Output | { folderPath: string, matchResult: { }, } |
recursive. goes up until it finds a folder that's an operation
because it had to read the package.json anyway, it's returning the operation classification as well
Input | ||
---|---|---|
startPath | string | |
Output | { folderPath: string, classification: { }, } |
Input | ||
---|---|---|
operation | Operation | |
Output | string[] |
Finds the common ancestor for two absolute pahts
Input | ||
---|---|---|
path1 | string | |
Output | String |
gets the relative path from a specified root
will start with "/"
Input | ||
---|---|---|
absolutePath | string | |
Output |
Input | ||
---|---|---|
operation | Operation | |
Output |
Input | ||
---|---|---|
tsconfig | { } | |
Output |
simple sync function to check if a folder is the root of a workspace (not operation but a workspace)
Input | ||
---|---|---|
folderPath | string | |
Output | { isBundle: boolean, isWorkspaceRoot: boolean, } |
Input | ||
---|---|---|
packageJson | { } | |
Output |
Input | ||
---|---|---|
tsconfig | TsConfig | |
Output | { } |
recursive. goes up a folder until it finds a package.json
recursive. goes up until it finds a folder that's an operation
because it had to read the package.json anyway, it's returning the operation classification as well
Finds the common ancestor for two absolute pahts
gets the relative path from a specified root
will start with "/"
simple sync function to check if a folder is the root of a workspace (not operation but a workspace)
can only be accessed in the OS
can be accessed in projects as well as in the OS
README
get-path (OperationClassification cjs)
Useful functions to get paths within King OS.
Depends on sdk-operations, which makes it only work inside of a typerepo.
returns project root folder path
recursive. goes up until it finds a folder that's the project root
if no source path is given, uses the directory name where the function is executed from as a starting point
Input | ||
---|---|---|
fullSourcePath (optional) | string | |
Output | string |
returns project root folder path
recursive. goes up until it finds a folder that's the project root
if no source path is given, uses the directory name where the function is executed from as a starting point
Makes a path relative using proper parsing
Resulting path will apply the paths conventions
- no slash at the end
- no slash at the beginning
Input | ||
---|---|---|
absolutePath | string | absolute path of a file or folder without a slash at the end |
Output | String |
Makes a path relative using proper parsing
Resulting path will apply the paths conventions
- no slash at the end
- no slash at the beginning
Input | ||
---|---|---|
startPath | string | |
Output | string |
Gets a path of any operation in the project
TODO: IDEA: maybe auto-generate key-value JSON where keys are the package-names of all operations and values are paths of their locations in the file system. we can easily generate this ourselves, but maybe it's also easy to use the npm yarn workspace for this, although it may not be available in all circumstances, so better not rely on it. The advantage of this would be that this function becomes sync and is much more efficient. The disadvantage is that every time you move something or add something new, this indexation has to happen, otherwise it fails.
Input | ||
---|---|---|
operationName | string | specify the operation folder name |
Output |
returns an array of all (absolute) paths containing operations
for a bundled project, that means /apps, /packages, /modules
for the OS project, that means /operations/tools and /operations/niches
Input | ||
---|---|---|
config (optional) | { manualProjectRoot?: string, } | |
Output | string[] |
returns an array of all (absolute) paths containing operations
for a bundled project, that means /apps, /packages, /modules
for the OS project, that means /operations/tools and /operations/niches
Gets project path, or a folder in the root that is convention
Input | ||
---|---|---|
- | ||
Output | string |
returns a file id (path without extension) relative to the src folder of an operation
e.g. "general" for src/general.ts
NB: assumes all src is in the src folder
NB: removes "/" in the beginning, if found
Input | ||
---|---|---|
operationRelativePath | string | |
Output |
returns a file id (path without extension) relative to the src folder of an operation
e.g. "general" for src/general.ts
NB: assumes all src is in the src folder
NB: removes "/" in the beginning, if found
Returns OperationClassification if it's an operation, or undefined if it's not
NB: don't confuse this with ImportClassification
Input | ||
---|---|---|
folderPath | string | |
Output |
Input | ||
---|---|---|
folderPath (optional) | string | |
Output | { } |
Returns OperationClassification if it's an operation, or undefined if it's not
NB: don't confuse this with ImportClassification
something like src/xxx/xxx/x.ts (no slash at start)
Input | ||
---|---|---|
absolutePath | string | |
Output |
something like src/xxx/xxx/x.ts (no slash at start)
get all operation-related path information that can be inferred from the path
NB: currently it also looks up the operation name from its packagejson
Input | ||
---|---|---|
absolutePath | string | |
Output |
gets all kinds of information that can be inferred from any path (file or folder).
Input | ||
---|---|---|
absolutePath | string | |
Output | { relativePathFromProjectRoot: string, } |
get all operation-related path information that can be inferred from the path
NB: currently it also looks up the operation name from its packagejson
gets all kinds of information that can be inferred from any path (file or folder).
Input | ||
---|---|---|
- | ||
Output |
returns a relative link between two files
Input | ||
---|---|---|
absoluteFromFilePath | string | |
Output | String |
Checks whether or not an absolute path contains an operation. The only check it's doing is that the folder must contain both a package.json as well as a tsconfig.json
Input | ||
---|---|---|
absoluteFolderPath | string | |
Output | { } |
returns a relative link between two files
Checks whether or not an absolute path contains an operation. The only check it's doing is that the folder must contain both a package.json as well as a tsconfig.json
Show test information(2)
Input | ||
---|---|---|
- | ||
Output |
Show internal (24)
recursive. goes up a folder until it finds a package.json
Input | ||
---|---|---|
- | ||
Output | { folderPath: string, matchResult: { }, } |
recursive. goes up until it finds a folder that's an operation
because it had to read the package.json anyway, it's returning the operation classification as well
Input | ||
---|---|---|
startPath | string | |
Output | { folderPath: string, classification: { }, } |
Input | ||
---|---|---|
operation | Operation | |
Output | string[] |
Finds the common ancestor for two absolute pahts
Input | ||
---|---|---|
path1 | string | |
Output | String |
gets the relative path from a specified root
will start with "/"
Input | ||
---|---|---|
absolutePath | string | |
Output |
Input | ||
---|---|---|
operation | Operation | |
Output |
Input | ||
---|---|---|
tsconfig | { } | |
Output |
simple sync function to check if a folder is the root of a workspace (not operation but a workspace)
Input | ||
---|---|---|
folderPath | string | |
Output | { isBundle: boolean, isWorkspaceRoot: boolean, } |
Input | ||
---|---|---|
packageJson | { } | |
Output |
Input | ||
---|---|---|
tsconfig | TsConfig | |
Output | { } |
recursive. goes up a folder until it finds a package.json
recursive. goes up until it finds a folder that's an operation
because it had to read the package.json anyway, it's returning the operation classification as well
Finds the common ancestor for two absolute pahts
gets the relative path from a specified root
will start with "/"
simple sync function to check if a folder is the root of a workspace (not operation but a workspace)
can only be accessed in the OS
can be accessed in projects as well as in the OS