React with Native

Bringing together React and React Native

GitHub

README

Get path

get-path (

OperationClassification

TODO: Ensure embedding this will embed the actual docs in my markdown renderer. I guess it might already do so!

TODO: It would be great to learn more about this topic and see if I can make more cross-environment packages. A great use case would be to create a wrapper around the current fs-orm to enable using it at the frontend too.

OperationClassification cjs)

Useful functions to get paths within King OS.

Depends on

sdk-operations

Generated operation that exports an object that contains all names of all operations as keys, and all project relative paths to those operations as values.

Needed to find files more quickly in a more performant way.

When moving operations around, ensure to regenerate this to avoid conflicts.

sdk-operations, which makes it only work inside of a typerepo.

Api reference
getProjectRoot()

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
Outputstring
📄 getProjectRoot (exported const)

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

makeRelative()

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
absolutePathstringabsolute path of a file or folder without a slash at the end
OutputString
📄 makeRelative (exported const)

Makes a path relative using proper parsing

Resulting path will apply the paths conventions

  • no slash at the end
  • no slash at the beginning
findOperationBasePath()
Input
startPathstring
Outputstring
getOperationPath()

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
operationNamestringspecify the operation folder name
Output
📄 findOperationBasePath (exported const)
📄 getOperationPath (exported const)
getPathsWithOperations()

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,
}
Outputstring[]
📄 getPathsWithOperations (exported const)

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

getRootPath()

Gets project path, or a folder in the root that is convention

Input
-
Outputstring
📄 getRootPath (exported const)
getSrcRelativeFileId()

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
operationRelativePathstring
Output
📄 getSrcRelativeFileId (exported const)

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

getOperationClassification()

Returns

OperationClassification

TODO: Ensure embedding this will embed the actual docs in my markdown renderer. I guess it might already do so!

TODO: It would be great to learn more about this topic and see if I can make more cross-environment packages. A great use case would be to create a wrapper around the current fs-orm to enable using it at the frontend too.

OperationClassification if it's an operation, or undefined if it's not

NB: don't confuse this with

ImportClassification

node: node core packages like fs and path

react: react standard packages like react, react-native, expo, react-dom, etc.

package: packages from npm that are not classified as operations

operation: operations from our monorepo

internal: imports from other places in the same operation

NB: don't confuse this with OperationClassification

ImportClassification

Input
folderPathstring
Output
isBundle()
Input
folderPath (optional)string
Output{ }
📄 getOperationClassification (exported const)

Returns

OperationClassification

TODO: Ensure embedding this will embed the actual docs in my markdown renderer. I guess it might already do so!

TODO: It would be great to learn more about this topic and see if I can make more cross-environment packages. A great use case would be to create a wrapper around the current fs-orm to enable using it at the frontend too.

OperationClassification if it's an operation, or undefined if it's not

NB: don't confuse this with

ImportClassification

node: node core packages like fs and path

react: react standard packages like react, react-native, expo, react-dom, etc.

package: packages from npm that are not classified as operations

operation: operations from our monorepo

internal: imports from other places in the same operation

NB: don't confuse this with OperationClassification

ImportClassification

📄 isBundle (exported const)
getOperationRelativePath()

something like src/xxx/xxx/x.ts (no slash at start)

Input
absolutePathstring
Output
📄 getOperationRelativePath (exported const)

something like src/xxx/xxx/x.ts (no slash at start)

getOperationPathParse()

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
absolutePathstring
Output
getPathParse()

gets all kinds of information that can be inferred from any path (file or folder).

Input
absolutePathstring
Output{ relativePathFromProjectRoot: string,
}
📄 getOperationPathParse (exported const)

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

📄 getPathParse (exported const)

gets all kinds of information that can be inferred from any path (file or folder).

getOperationClassificationObject()
Input
-
Output
getRelativeLinkPath()

returns a relative link between two files

Input
absoluteFromFilePathstring
OutputString
isOperation()

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
absoluteFolderPathstring
Output{ }
🔹 OperationClassificationObject
📄 getOperationClassificationObject (exported const)
📄 getRelativeLinkPath (exported const)

returns a relative link between two files

📄 isOperation (exported const)

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

Tests
Show test information(2)
test()
Input
-
Output
📄 test (unexported const)
Internal
Show internal (24)
findFolderWhereMatch()

recursive. goes up a folder until it finds a package.json

Input
-
Output{ folderPath: string,
matchResult: { },
}
findOperationBasePathWithClassification()

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
startPathstring
Output{ folderPath: string,
classification: { },
}
getAllPackageJsonDependencies()
Input
operationOperation
Outputstring[]
getCommonAncestor()

Finds the common ancestor for two absolute pahts

Input
path1string
OutputString
getRelativePath()

gets the relative path from a specified root

will start with "/"

Input
absolutePathstring
Output
hasDependency()
Input
operationOperation
Output
isUiOperation()
Input
tsconfig{ }
Output
isWorkspaceRoot()

simple sync function to check if a folder is the root of a workspace (not operation but a workspace)

Input
folderPathstring
Output{ isBundle: boolean,
isWorkspaceRoot: boolean,
}
packageCompilesTs()
Input
packageJson{ }
Output
tsconfigCompilesEsm()
Input
tsconfigTsConfig
Output{ }
📄 findFolderWhereMatch (exported const)

recursive. goes up a folder until it finds a package.json

📄 findOperationBasePathWithClassification (exported const)

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

📄 getAllPackageJsonDependencies (exported const)
📄 getCommonAncestor (exported const)

Finds the common ancestor for two absolute pahts

📄 getRelativePath (exported const)

gets the relative path from a specified root

will start with "/"

📄 hasDependency (exported const)
📄 isUiOperation (exported const)
📄 isWorkspaceRoot (exported const)

simple sync function to check if a folder is the root of a workspace (not operation but a workspace)

📄 osRootFoldersConst (exported const)

can only be accessed in the OS

📄 osRootFolders (exported const)
📄 packageCompilesTs (exported const)
📄 projectRootFoldersConst (exported const)

can be accessed in projects as well as in the OS

📄 projectRootFolders (exported const)
📄 tsconfigCompilesEsm (exported const)