@jakubmazanec/carson 0.1.0-a500263 → 0.1.0-bc209e5
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/README.md +125 -12
- package/dist/commands/create-project/CreateProject.js +2 -2
- package/dist/commands/create-project/CreateProject.js.map +1 -1
- package/dist/commands/create-project/CreateProjectInput.js +1 -1
- package/dist/commands/create-project/CreateProjectInput.js.map +1 -1
- package/dist/commands/create-project/createProjectCommand.js +3 -4
- package/dist/commands/create-project/createProjectCommand.js.map +1 -1
- package/dist/commands/create-project/runCreateProject.js +4 -14
- package/dist/commands/create-project/runCreateProject.js.map +1 -1
- package/dist/commands/create-workspace/CreateWorkspace.d.ts +1 -2
- package/dist/commands/create-workspace/CreateWorkspace.js +7 -5
- package/dist/commands/create-workspace/CreateWorkspace.js.map +1 -1
- package/dist/commands/create-workspace/CreateWorkspaceInput.js.map +1 -1
- package/dist/commands/create-workspace/createWorkspaceCommand.js +1 -11
- package/dist/commands/create-workspace/createWorkspaceCommand.js.map +1 -1
- package/dist/commands/create-workspace/runCreateWorkspace.js +4 -13
- package/dist/commands/create-workspace/runCreateWorkspace.js.map +1 -1
- package/dist/commands/internals/CommandStatus.d.ts +1 -0
- package/dist/commands/internals/CommandStatus.js +3 -0
- package/dist/commands/internals/CommandStatus.js.map +1 -0
- package/dist/commands/internals/packageNameToDirectory.js.map +1 -1
- package/dist/commands/internals.d.ts +1 -0
- package/dist/commands/internals.js +1 -0
- package/dist/commands/internals.js.map +1 -1
- package/dist/commands/update-workspace/UpdateWorkspace.js +3 -3
- package/dist/commands/update-workspace/UpdateWorkspace.js.map +1 -1
- package/dist/commands/update-workspace/runUpdateWorkspace.js +1 -1
- package/dist/commands/update-workspace/runUpdateWorkspace.js.map +1 -1
- package/dist/commands/update-workspace/updateWorkspaceCommand.js +3 -4
- package/dist/commands/update-workspace/updateWorkspaceCommand.js.map +1 -1
- package/dist/constants.js +0 -4
- package/dist/constants.js.map +1 -1
- package/dist/run.js.map +1 -1
- package/dist/template/CarsonTemplate.d.ts +6 -0
- package/dist/template/CarsonTemplate.js.map +1 -1
- package/dist/template/CarsonTemplateConfig.d.ts +3 -0
- package/dist/template/CarsonTemplateConfig.js.map +1 -1
- package/dist/template/CarsonTemplateError.d.ts +8 -0
- package/dist/template/CarsonTemplateError.js +13 -0
- package/dist/template/CarsonTemplateError.js.map +1 -0
- package/dist/template/TemplateAttributes.d.ts +3 -3
- package/dist/template/TemplateAttributes.js +13 -11
- package/dist/template/TemplateAttributes.js.map +1 -1
- package/dist/template/TemplateData.d.ts +0 -18
- package/dist/template/TemplateData.js +1 -3
- package/dist/template/TemplateData.js.map +1 -1
- package/dist/template/TemplateRender.d.ts +8 -1
- package/dist/template/TemplateRender.js.map +1 -1
- package/dist/template/TemplateRenders.d.ts +3 -0
- package/dist/template/TemplateRenders.js.map +1 -1
- package/dist/template/applyTemplateRenders.d.ts +5 -3
- package/dist/template/applyTemplateRenders.js +51 -21
- package/dist/template/applyTemplateRenders.js.map +1 -1
- package/dist/template/internals/TemplateRenderSnapshot.d.ts +40 -0
- package/dist/template/{TemplateRenderSnapshot.js → internals/TemplateRenderSnapshot.js} +5 -2
- package/dist/template/internals/TemplateRenderSnapshot.js.map +1 -0
- package/dist/template/internals/TemplateRenderSnapshots.d.ts +40 -0
- package/dist/template/internals/TemplateRenderSnapshots.js.map +1 -0
- package/dist/template/internals/createUsingTemplateRender.d.ts +3 -0
- package/dist/template/internals/createUsingTemplateRender.js +12 -0
- package/dist/template/internals/createUsingTemplateRender.js.map +1 -0
- package/dist/template/internals/deleteUsingTemplateRender.d.ts +6 -0
- package/dist/template/internals/deleteUsingTemplateRender.js +23 -0
- package/dist/template/internals/deleteUsingTemplateRender.js.map +1 -0
- package/dist/template/internals/importCarsonTemplate.js +8 -0
- package/dist/template/internals/importCarsonTemplate.js.map +1 -0
- package/dist/template/internals/insertUsingTemplateRender.d.ts +3 -0
- package/dist/template/internals/insertUsingTemplateRender.js +41 -0
- package/dist/template/internals/insertUsingTemplateRender.js.map +1 -0
- package/dist/template/internals/loadTemplateRenderSnapshots.d.ts +10 -0
- package/dist/template/internals/loadTemplateRenderSnapshots.js.map +1 -0
- package/dist/template/internals/merge.js.map +1 -1
- package/dist/template/internals/mergeUsingTemplateRender.d.ts +3 -0
- package/dist/template/{mergeFileUsingTemplateRender.js → internals/mergeUsingTemplateRender.js} +18 -7
- package/dist/template/internals/mergeUsingTemplateRender.js.map +1 -0
- package/dist/template/internals/overwriteUsingTemplateRender.d.ts +3 -0
- package/dist/template/internals/overwriteUsingTemplateRender.js +12 -0
- package/dist/template/internals/overwriteUsingTemplateRender.js.map +1 -0
- package/dist/template/internals/parseCarsonTemplateId.d.ts +1 -0
- package/dist/template/internals/parseCarsonTemplateId.js +17 -0
- package/dist/template/internals/parseCarsonTemplateId.js.map +1 -0
- package/dist/template/internals/prettify.js.map +1 -1
- package/dist/template/{readCarsonTemplate.d.ts → internals/readCarsonTemplate.d.ts} +1 -1
- package/dist/template/{readCarsonTemplate.js → internals/readCarsonTemplate.js} +14 -8
- package/dist/template/internals/readCarsonTemplate.js.map +1 -0
- package/dist/template/internals/resolveModule.d.ts +1 -0
- package/dist/template/{resolveTemplateModule.js → internals/resolveModule.js} +2 -2
- package/dist/template/internals/resolveModule.js.map +1 -0
- package/dist/template/{saveTemplateRenderSnapshots.d.ts → internals/saveTemplateRenderSnapshots.d.ts} +1 -1
- package/dist/template/{saveTemplateRenderSnapshots.js → internals/saveTemplateRenderSnapshots.js} +4 -4
- package/dist/template/internals/saveTemplateRenderSnapshots.js.map +1 -0
- package/dist/template/internals/uninsertUsingTemplateRender.d.ts +3 -0
- package/dist/template/internals/uninsertUsingTemplateRender.js +41 -0
- package/dist/template/internals/uninsertUsingTemplateRender.js.map +1 -0
- package/dist/template/internals/unmerge.d.ts +1 -1
- package/dist/template/internals/unmerge.js +1 -1
- package/dist/template/internals/unmerge.js.map +1 -1
- package/dist/template/internals/unmergeUsingTemplateRender.d.ts +3 -0
- package/dist/template/{unmergeFileUsingTemplateRender.js → internals/unmergeUsingTemplateRender.js} +18 -7
- package/dist/template/internals/unmergeUsingTemplateRender.js.map +1 -0
- package/dist/template/internals.d.ts +16 -1
- package/dist/template/internals.js +16 -1
- package/dist/template/internals.js.map +1 -1
- package/dist/template/renderCarsonTemplate.d.ts +10 -0
- package/dist/template/renderCarsonTemplate.js +34 -0
- package/dist/template/renderCarsonTemplate.js.map +1 -0
- package/dist/template.d.ts +2 -13
- package/dist/template.js +2 -13
- package/dist/template.js.map +1 -1
- package/dist/workspace/Project.d.ts +2 -2
- package/dist/workspace/Project.js +31 -14
- package/dist/workspace/Project.js.map +1 -1
- package/dist/workspace/ProjectConfig.d.ts +3 -0
- package/dist/workspace/ProjectConfig.js.map +1 -1
- package/dist/workspace/ProjectCreateOptions.d.ts +3 -0
- package/dist/workspace/ProjectCreateOptions.js.map +1 -1
- package/dist/workspace/ProjectError.d.ts +5 -2
- package/dist/workspace/ProjectError.js +6 -2
- package/dist/workspace/ProjectError.js.map +1 -1
- package/dist/workspace/ProjectOptions.d.ts +1 -1
- package/dist/workspace/ProjectOptions.js.map +1 -1
- package/dist/workspace/ProjectUpdateOptions.d.ts +3 -0
- package/dist/workspace/ProjectUpdateOptions.js +3 -1
- package/dist/workspace/ProjectUpdateOptions.js.map +1 -1
- package/dist/workspace/Workspace.d.ts +8 -6
- package/dist/workspace/Workspace.js +114 -46
- package/dist/workspace/Workspace.js.map +1 -1
- package/dist/workspace/WorkspaceConfig.d.ts +3 -0
- package/dist/workspace/WorkspaceConfig.js.map +1 -1
- package/dist/workspace/WorkspaceCreateOptions.d.ts +3 -0
- package/dist/workspace/WorkspaceCreateOptions.js +3 -1
- package/dist/workspace/WorkspaceCreateOptions.js.map +1 -1
- package/dist/workspace/WorkspaceCreateProjectOptions.d.ts +3 -0
- package/dist/workspace/WorkspaceCreateProjectOptions.js +3 -1
- package/dist/workspace/WorkspaceCreateProjectOptions.js.map +1 -1
- package/dist/workspace/WorkspaceDependencies.d.ts +26 -22
- package/dist/workspace/WorkspaceDependencies.js +34 -13
- package/dist/workspace/WorkspaceDependencies.js.map +1 -1
- package/dist/workspace/WorkspaceDependenciesFromWorkspaceOptions.d.ts +8 -0
- package/dist/workspace/WorkspaceDependenciesFromWorkspaceOptions.js +5 -0
- package/dist/workspace/WorkspaceDependenciesFromWorkspaceOptions.js.map +1 -0
- package/dist/workspace/WorkspaceDependenciesGetVersionsOptions.d.ts +6 -0
- package/dist/workspace/WorkspaceDependenciesGetVersionsOptions.js +5 -0
- package/dist/workspace/WorkspaceDependenciesGetVersionsOptions.js.map +1 -0
- package/dist/workspace/WorkspaceDependency.d.ts +14 -0
- package/dist/workspace/WorkspaceDependency.js +3 -0
- package/dist/workspace/WorkspaceDependency.js.map +1 -0
- package/dist/workspace/WorkspaceDependencyProject.d.ts +11 -0
- package/dist/workspace/WorkspaceDependencyProject.js +5 -0
- package/dist/workspace/WorkspaceDependencyProject.js.map +1 -0
- package/dist/workspace/WorkspaceError.d.ts +5 -2
- package/dist/workspace/WorkspaceError.js +10 -3
- package/dist/workspace/WorkspaceError.js.map +1 -1
- package/dist/workspace/WorkspaceFindAndReadOptions.d.ts +6 -0
- package/dist/workspace/WorkspaceFindAndReadOptions.js +5 -0
- package/dist/workspace/WorkspaceFindAndReadOptions.js.map +1 -0
- package/dist/workspace/WorkspaceOptions.d.ts +4 -4
- package/dist/workspace/WorkspaceOptions.js.map +1 -1
- package/dist/workspace/{WorkspaceOptionsProjectOptions.d.ts → WorkspaceOptionsProject.d.ts} +4 -1
- package/dist/workspace/WorkspaceOptionsProject.js +3 -0
- package/dist/workspace/WorkspaceOptionsProject.js.map +1 -0
- package/dist/workspace/WorkspacePackageJson.d.ts +3 -0
- package/dist/workspace/WorkspacePackageJson.js.map +1 -1
- package/dist/workspace/WorkspaceProjectGlobs.d.ts +3 -0
- package/dist/workspace/WorkspaceProjectGlobs.js +3 -1
- package/dist/workspace/WorkspaceProjectGlobs.js.map +1 -1
- package/dist/workspace/WorkspaceProjects.d.ts +3 -0
- package/dist/workspace/WorkspaceProjects.js.map +1 -1
- package/dist/workspace/WorkspaceRepository.d.ts +3 -0
- package/dist/workspace/WorkspaceRepository.js +3 -1
- package/dist/workspace/WorkspaceRepository.js.map +1 -1
- package/dist/workspace/WorkspaceUpdateOptions.d.ts +3 -0
- package/dist/workspace/WorkspaceUpdateOptions.js +3 -1
- package/dist/workspace/WorkspaceUpdateOptions.js.map +1 -1
- package/dist/workspace/internals/compareProjectPath.d.ts +2 -0
- package/dist/workspace/internals/compareProjectPath.js +10 -0
- package/dist/workspace/internals/compareProjectPath.js.map +1 -0
- package/dist/workspace/internals/compareSemver.js.map +1 -1
- package/dist/workspace/internals/compareWorkspaceDependencyProjectName.d.ts +2 -0
- package/dist/workspace/internals/compareWorkspaceDependencyProjectName.js +10 -0
- package/dist/workspace/internals/compareWorkspaceDependencyProjectName.js.map +1 -0
- package/dist/workspace/internals/getPackageJsonWorkspaces.js.map +1 -1
- package/dist/workspace/internals/getRepositoryBranches.js.map +1 -1
- package/dist/workspace/internals/getRepositoryUrl.js +1 -2
- package/dist/workspace/internals/getRepositoryUrl.js.map +1 -1
- package/dist/workspace/internals.d.ts +2 -0
- package/dist/workspace/internals.js +2 -0
- package/dist/workspace/internals.js.map +1 -1
- package/dist/workspace/saveProjectConfig.d.ts +8 -0
- package/dist/workspace/saveProjectConfig.js +5 -1
- package/dist/workspace/saveProjectConfig.js.map +1 -1
- package/dist/workspace/saveWorkspaceConfig.d.ts +8 -0
- package/dist/workspace/saveWorkspaceConfig.js +5 -1
- package/dist/workspace/saveWorkspaceConfig.js.map +1 -1
- package/dist/workspace.d.ts +12 -0
- package/dist/workspace.js +12 -0
- package/dist/workspace.js.map +1 -1
- package/package.json +9 -10
- package/src/commands/create-project/CreateProject.tsx +2 -2
- package/src/commands/create-project/CreateProjectInput.ts +1 -1
- package/src/commands/create-project/createProjectCommand.tsx +1 -5
- package/src/commands/create-project/runCreateProject.ts +4 -17
- package/src/commands/create-workspace/CreateWorkspace.tsx +7 -5
- package/src/commands/create-workspace/createWorkspaceCommand.tsx +1 -14
- package/src/commands/create-workspace/runCreateWorkspace.ts +4 -16
- package/src/commands/internals/CommandStatus.ts +1 -0
- package/src/commands/internals.ts +1 -0
- package/src/commands/update-workspace/UpdateWorkspace.tsx +1 -1
- package/src/commands/update-workspace/updateWorkspaceCommand.tsx +1 -5
- package/src/constants.ts +0 -8
- package/src/template/CarsonTemplate.ts +8 -0
- package/src/template/CarsonTemplateConfig.ts +3 -0
- package/src/template/CarsonTemplateError.ts +19 -0
- package/src/template/TemplateAttributes.ts +11 -8
- package/src/template/TemplateData.ts +0 -2
- package/src/template/TemplateRender.ts +8 -1
- package/src/template/TemplateRenders.ts +3 -0
- package/src/template/applyTemplateRenders.ts +77 -23
- package/src/template/{TemplateRenderSnapshot.ts → internals/TemplateRenderSnapshot.ts} +6 -1
- package/src/template/internals/createUsingTemplateRender.ts +16 -0
- package/src/template/internals/deleteUsingTemplateRender.ts +35 -0
- package/src/template/{importCarsonTemplate.ts → internals/importCarsonTemplate.ts} +2 -2
- package/src/template/internals/insertUsingTemplateRender.ts +49 -0
- package/src/template/internals/mergeUsingTemplateRender.ts +54 -0
- package/src/template/internals/overwriteUsingTemplateRender.ts +16 -0
- package/src/template/internals/parseCarsonTemplateId.ts +13 -0
- package/src/template/{readCarsonTemplate.ts → internals/readCarsonTemplate.ts} +12 -9
- package/src/template/{resolveTemplateModule.ts → internals/resolveModule.ts} +1 -1
- package/src/template/{saveTemplateRenderSnapshots.ts → internals/saveTemplateRenderSnapshots.ts} +4 -3
- package/src/template/internals/uninsertUsingTemplateRender.ts +49 -0
- package/src/template/internals/unmerge.ts +1 -1
- package/src/template/{unmergeFileUsingTemplateRender.ts → internals/unmergeUsingTemplateRender.ts} +19 -7
- package/src/template/internals.ts +16 -1
- package/src/template/renderCarsonTemplate.ts +59 -0
- package/src/template.ts +2 -13
- package/src/workspace/Project.ts +21 -11
- package/src/workspace/ProjectConfig.ts +3 -0
- package/src/workspace/ProjectCreateOptions.ts +3 -0
- package/src/workspace/ProjectError.ts +5 -0
- package/src/workspace/ProjectOptions.ts +1 -1
- package/src/workspace/ProjectUpdateOptions.ts +3 -0
- package/src/workspace/Workspace.ts +122 -49
- package/src/workspace/WorkspaceConfig.ts +3 -0
- package/src/workspace/WorkspaceCreateOptions.ts +3 -0
- package/src/workspace/WorkspaceCreateProjectOptions.ts +3 -0
- package/src/workspace/WorkspaceDependencies.ts +30 -31
- package/src/workspace/WorkspaceDependenciesFromWorkspaceOptions.ts +8 -0
- package/src/workspace/WorkspaceDependenciesGetVersionsOptions.ts +6 -0
- package/src/workspace/WorkspaceDependency.ts +18 -0
- package/src/workspace/WorkspaceDependencyProject.ts +13 -0
- package/src/workspace/WorkspaceError.ts +10 -1
- package/src/workspace/WorkspaceFindAndReadOptions.ts +6 -0
- package/src/workspace/WorkspaceOptions.ts +4 -4
- package/src/workspace/{WorkspaceOptionsProjectOptions.ts → WorkspaceOptionsProject.ts} +4 -1
- package/src/workspace/WorkspacePackageJson.ts +3 -0
- package/src/workspace/WorkspaceProjectGlobs.ts +3 -0
- package/src/workspace/WorkspaceProjects.ts +3 -0
- package/src/workspace/WorkspaceRepository.ts +3 -0
- package/src/workspace/WorkspaceUpdateOptions.ts +3 -0
- package/src/workspace/internals/compareProjectPath.ts +14 -0
- package/src/workspace/internals/compareWorkspaceDependencyProjectName.ts +14 -0
- package/src/workspace/internals/getRepositoryUrl.ts +0 -1
- package/src/workspace/internals.ts +2 -0
- package/src/workspace/saveProjectConfig.ts +8 -0
- package/src/workspace/saveWorkspaceConfig.ts +8 -0
- package/src/workspace.ts +12 -0
- package/dist/template/TemplateRenderSnapshot.d.ts +0 -27
- package/dist/template/TemplateRenderSnapshot.js.map +0 -1
- package/dist/template/TemplateRenderSnapshots.d.ts +0 -27
- package/dist/template/TemplateRenderSnapshots.js.map +0 -1
- package/dist/template/createFileUsingTemplateRender.d.ts +0 -2
- package/dist/template/createFileUsingTemplateRender.js +0 -12
- package/dist/template/createFileUsingTemplateRender.js.map +0 -1
- package/dist/template/deleteFileUsingTemplateRender.d.ts +0 -2
- package/dist/template/deleteFileUsingTemplateRender.js +0 -10
- package/dist/template/deleteFileUsingTemplateRender.js.map +0 -1
- package/dist/template/importCarsonTemplate.js +0 -8
- package/dist/template/importCarsonTemplate.js.map +0 -1
- package/dist/template/insertUsingTemplateRender.d.ts +0 -2
- package/dist/template/insertUsingTemplateRender.js +0 -29
- package/dist/template/insertUsingTemplateRender.js.map +0 -1
- package/dist/template/loadTemplateRenderSnapshots.d.ts +0 -7
- package/dist/template/loadTemplateRenderSnapshots.js.map +0 -1
- package/dist/template/mergeFileUsingTemplateRender.d.ts +0 -2
- package/dist/template/mergeFileUsingTemplateRender.js.map +0 -1
- package/dist/template/overwriteFileUsingTemplateRender.d.ts +0 -2
- package/dist/template/overwriteFileUsingTemplateRender.js +0 -12
- package/dist/template/overwriteFileUsingTemplateRender.js.map +0 -1
- package/dist/template/parseTemplateId.d.ts +0 -1
- package/dist/template/parseTemplateId.js +0 -12
- package/dist/template/parseTemplateId.js.map +0 -1
- package/dist/template/readCarsonTemplate.js.map +0 -1
- package/dist/template/renderTemplate.d.ts +0 -7
- package/dist/template/renderTemplate.js +0 -19
- package/dist/template/renderTemplate.js.map +0 -1
- package/dist/template/resolveTemplateModule.d.ts +0 -1
- package/dist/template/resolveTemplateModule.js.map +0 -1
- package/dist/template/saveTemplateRenderSnapshots.js.map +0 -1
- package/dist/template/uninsertUsingTemplateRender.d.ts +0 -2
- package/dist/template/uninsertUsingTemplateRender.js +0 -29
- package/dist/template/uninsertUsingTemplateRender.js.map +0 -1
- package/dist/template/unmergeFileUsingTemplateRender.d.ts +0 -2
- package/dist/template/unmergeFileUsingTemplateRender.js.map +0 -1
- package/dist/workspace/WorkspaceOptionsProjectOptions.js +0 -3
- package/dist/workspace/WorkspaceOptionsProjectOptions.js.map +0 -1
- package/src/template/createFileUsingTemplateRender.ts +0 -12
- package/src/template/deleteFileUsingTemplateRender.ts +0 -15
- package/src/template/insertUsingTemplateRender.ts +0 -33
- package/src/template/mergeFileUsingTemplateRender.ts +0 -39
- package/src/template/overwriteFileUsingTemplateRender.ts +0 -12
- package/src/template/parseTemplateId.ts +0 -9
- package/src/template/renderTemplate.ts +0 -30
- package/src/template/uninsertUsingTemplateRender.ts +0 -36
- /package/dist/template/{TemplateRenderSnapshots.js → internals/TemplateRenderSnapshots.js} +0 -0
- /package/dist/template/{importCarsonTemplate.d.ts → internals/importCarsonTemplate.d.ts} +0 -0
- /package/dist/template/{loadTemplateRenderSnapshots.js → internals/loadTemplateRenderSnapshots.js} +0 -0
- /package/src/template/{TemplateRenderSnapshots.ts → internals/TemplateRenderSnapshots.ts} +0 -0
- /package/src/template/{loadTemplateRenderSnapshots.ts → internals/loadTemplateRenderSnapshots.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
<!-- header -->
|
|
1
2
|
<div align="center">
|
|
2
3
|
|
|
3
4
|
# @jakubmazanec/carson
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Tool for managing workspace and project configuration.
|
|
6
7
|
|
|
7
8
|
</div>
|
|
9
|
+
<!-- header -->
|
|
8
10
|
|
|
9
11
|
## Installation
|
|
10
12
|
|
|
@@ -47,7 +49,7 @@ See [CLI documentation](#cli) for the complete overview.
|
|
|
47
49
|
### How it works
|
|
48
50
|
|
|
49
51
|
Carson assumes your codebase is organized in a workspace, which is simply a directory, and also
|
|
50
|
-
usually a
|
|
52
|
+
usually a Git repository, that contains one or multiple projects. A project is a self-contained
|
|
51
53
|
piece of code, e.g. a package, or an app.
|
|
52
54
|
|
|
53
55
|
> ⚠️ Currently only Node.js projects are supported.
|
|
@@ -100,8 +102,9 @@ YAML front matter. Please read [`@jakubmazanec/template` documentation](../templ
|
|
|
100
102
|
find out in more detail how they work. Simply, they're for generating content using JavaScript as a
|
|
101
103
|
templating language.
|
|
102
104
|
|
|
103
|
-
> Yes, each "Carson template" is composed of multiple
|
|
104
|
-
> these two different
|
|
105
|
+
> Yes, each "Carson template" is composed of multiple template files, and each of these files
|
|
106
|
+
> contains an "EJS template". Hopefully, the existence of these two different templates "types"
|
|
107
|
+
> isn't very confusing.
|
|
105
108
|
|
|
106
109
|
Take a look at this simplified example of `carson-templates` with two templates named `workspace`
|
|
107
110
|
and `project`:
|
|
@@ -146,13 +149,13 @@ strategy: merge
|
|
|
146
149
|
When Carson performs a workspace update, `carson-templates:project` template is rendered for each
|
|
147
150
|
project that uses it, and `foo`, and `bar` have their files changed accordingly. In this example
|
|
148
151
|
that means `foo/package.json` and `bar/package.json` are recursively merged with the JSONs obtained
|
|
149
|
-
from the EJS template above (
|
|
150
|
-
|
|
151
|
-
`'packages/
|
|
152
|
-
|
|
152
|
+
from the EJS template above (SWC is added to development dependencies, field `repository.directory`
|
|
153
|
+
is set to always be the value of a variable `project.relativePath`, i.e. `'packages/foo'` or
|
|
154
|
+
`'packages/bar'`, and so on). Updating the workspace works the same way (although using a different
|
|
155
|
+
Carson template, e.g. `carson-templates:workspace`).
|
|
153
156
|
|
|
154
157
|
When you install a newer version of `carson-templates` that e.g. replaces SWC with another tool,
|
|
155
|
-
before Carson does fresh update, it first uses saved (and committed to
|
|
158
|
+
before Carson does a fresh update, it first uses saved (and committed to Git) snapshots from the
|
|
156
159
|
previous update to revert all its changes. This way you don't need to keep the previous version of
|
|
157
160
|
`carson-templates` around and the updates can be always done automatically from the current state of
|
|
158
161
|
the workspace.
|
|
@@ -174,8 +177,8 @@ See [API reference](./docs) for auto-generated documentation.
|
|
|
174
177
|
### Configuration
|
|
175
178
|
|
|
176
179
|
Carson configuration files are located in a directory named `.carson` directory. Files named
|
|
177
|
-
`workspace.json` and `project.json` are used to configure workspace and project respectively (in
|
|
178
|
-
case of single-project workspace they're both in the same `.carson` directory).
|
|
180
|
+
`workspace.json` and `project.json` are used to configure the workspace and project respectively (in
|
|
181
|
+
the case of single-project workspace they're both in the same `.carson` directory).
|
|
179
182
|
|
|
180
183
|
You can add arbitrary data to these JSONs in addition to the options described below. Because
|
|
181
184
|
workspace and project configurations are available as JavaScript variables during the rendering of
|
|
@@ -200,6 +203,8 @@ configuration.
|
|
|
200
203
|
|
|
201
204
|
Updates workspace and all projects using the configured Carson templates.
|
|
202
205
|
|
|
206
|
+
> ⚠️ Make sure to have committed all changes to Git, in case the update doesn't work as you expect.
|
|
207
|
+
|
|
203
208
|
| Option | Description |
|
|
204
209
|
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
205
210
|
| --path | Path to the workspace. A relative path is appended to the current working directory. The file system is traversed up to the root when looking for a workspace. |
|
|
@@ -225,7 +230,115 @@ Creates new workspace.
|
|
|
225
230
|
|
|
226
231
|
### Carson templates
|
|
227
232
|
|
|
228
|
-
|
|
233
|
+
Carson template is just a directory containing `*.ejs` files and `config.json` file. The purpose of
|
|
234
|
+
a Carson template is to describe what files with what content should exist in a project or workspace
|
|
235
|
+
the template is applied to.
|
|
236
|
+
|
|
237
|
+
Carson templates are identified using a template ID consisting of two colon-separated parts: a bare
|
|
238
|
+
module specifier and a template name, e.g. `@jakubmazanec/carson-templates:projects/library`.
|
|
239
|
+
|
|
240
|
+
Because of this, you should organize your Carson templates by putting all of them into a single
|
|
241
|
+
package that has to look like this:
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
carson-templates@1.0.0/
|
|
245
|
+
├── src/
|
|
246
|
+
│ └── main.js
|
|
247
|
+
├── templates/
|
|
248
|
+
│ ├── projects/
|
|
249
|
+
│ │ ├── app/
|
|
250
|
+
│ │ │ ├── config.json
|
|
251
|
+
│ │ │ └── package.json.ejs
|
|
252
|
+
│ │ └── library/
|
|
253
|
+
│ │ ├── config.json
|
|
254
|
+
│ │ └── package.json.ejs
|
|
255
|
+
│ └── workspace/
|
|
256
|
+
│ ├── config.json
|
|
257
|
+
│ └── package.json.ejs
|
|
258
|
+
└── package.json
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
This package must export `package.json` and right next to it contain a directory named `templates`
|
|
262
|
+
in which each template is located (under a path that corresponds to its name). In the example above,
|
|
263
|
+
there are 3 templates (for simplicity, each contains only one `*.ejs` file and a config file):
|
|
264
|
+
|
|
265
|
+
1. `carson-templates:projects/app` located in `templates/projects/app`.
|
|
266
|
+
2. `carson-templates:projects/library` located in `templates/projects/library`.
|
|
267
|
+
3. `carson-templates:workspace` located in `templates/workspace`.
|
|
268
|
+
|
|
269
|
+
The package can also export some JavaScript code (defined in the `package.json` as usual); all named
|
|
270
|
+
export are available as global variables during the rendering of the template files.
|
|
271
|
+
|
|
272
|
+
#### Template files
|
|
273
|
+
|
|
274
|
+
All those `*.ejs` files are parsed and rendered via `@jakubmazanec/template` package; they are
|
|
275
|
+
actually [EJS](https://ejs.co/) templates with YAML front matter. Please read
|
|
276
|
+
[`@jakubmazanec/template` documentation](../template/README.md) to find out in more detail how they
|
|
277
|
+
work. Simply, they're for generating content using JavaScript as a templating language.
|
|
278
|
+
|
|
279
|
+
For a quick overview, look at the file `templates/projects/library/package.json.ejs`:
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
---
|
|
283
|
+
to: 'package.json'
|
|
284
|
+
strategy: merge
|
|
285
|
+
---
|
|
286
|
+
{
|
|
287
|
+
"repository": {
|
|
288
|
+
"directory": "<%- project.relativePath %>"
|
|
289
|
+
},
|
|
290
|
+
"type": "module",
|
|
291
|
+
"exports": "./dist/main.js",
|
|
292
|
+
"files": [
|
|
293
|
+
"dist",
|
|
294
|
+
"src"
|
|
295
|
+
],
|
|
296
|
+
"scripts": {
|
|
297
|
+
"build": "swc src -d dist"
|
|
298
|
+
},
|
|
299
|
+
"devDependencies": {
|
|
300
|
+
"@swc/cli": "^0.1.62",
|
|
301
|
+
"@swc/core": "^1.3.56"
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
The YAML front matter contains metadata describing what to do with the content generated during the
|
|
307
|
+
rendering of the EJS template.
|
|
308
|
+
|
|
309
|
+
Attribute `to` is the path of the target file the resulting template render is supposed to be
|
|
310
|
+
written into. The path is appended to the project or workspace path. The extension is also used for
|
|
311
|
+
file format detection by Prettier.
|
|
312
|
+
|
|
313
|
+
Attribute `strategy` describes how exactly should the template render be written, or whether it
|
|
314
|
+
should be written at all.
|
|
315
|
+
|
|
316
|
+
| Strategy name | Example `strategy` value | Description |
|
|
317
|
+
| ------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
318
|
+
| Create | `create` | The template render is written to the target file, but only when the Carson template is used to create a new workspace or project; when Carson performs an update, the template files with this strategy are not even rendered. |
|
|
319
|
+
| Ensure | `ensure` | The template render is written to the target file, but only when the target file doesn't exist; if it does, it is left unchanged. |
|
|
320
|
+
| Overwrite | `overwrite` | The template render is written to the target file, overwriting its existing content. |
|
|
321
|
+
| Merge | `merge` | The template render is merged with the target file's existing content. Only simple objects, not arrays, are merged recursively. The only supported file formats are JSON and YAML. |
|
|
322
|
+
| Check | `check` | Only the target file's existence is checked, the template render is discarded; when Carson doesn't perform an update, the template files with this strategy are not even rendered. |
|
|
323
|
+
| Insert | `[insert, foobar]` | The template render is inserted between the first and last occurrence of an HTML comment containing configured string, e.g. `<!-- foobar -->`. The only supported file format is Markdown. |
|
|
324
|
+
|
|
325
|
+
The rest of the template file after the front matter is the actual EJS template.
|
|
326
|
+
|
|
327
|
+
> ⚠️ Because EJS templates can contain arbitrary JavaScript code which Carson will run, you
|
|
328
|
+
> shouldn't use Carson templates from untrusted sources! Only use templates that you've written or
|
|
329
|
+
> extensively reviewed.
|
|
330
|
+
|
|
331
|
+
Global variables available during the rendering:
|
|
332
|
+
|
|
333
|
+
| Variable name | Description |
|
|
334
|
+
| ------------- | ------------------------------------------------------------------------------------- |
|
|
335
|
+
| `workspace` | The workspace Carson is being run in. |
|
|
336
|
+
| `project` | The project Carson is creating or updating; is undefined when working on a workspace. |
|
|
337
|
+
| `args` | Parsed command line arguments that were used to execute Carson. |
|
|
338
|
+
|
|
339
|
+
#### Carson template config
|
|
340
|
+
|
|
341
|
+
Currently, the config isn't used for anything yet.
|
|
229
342
|
|
|
230
343
|
## Contributing
|
|
231
344
|
|
|
@@ -8,7 +8,7 @@ import { CreateProjectInput } from './CreateProjectInput.js';
|
|
|
8
8
|
import { runCreateProject } from './runCreateProject.js';
|
|
9
9
|
import { packageNameToDirectory } from '../internals.js';
|
|
10
10
|
const ONLY_ONE_STAR_REGEXP = /^(?!(.*?\*){2,}|.*? |\*$).*?\*.*$/;
|
|
11
|
-
export function CreateProject({ args
|
|
11
|
+
export function CreateProject({ args, workspace }) {
|
|
12
12
|
let [status, setStatus] = useState('not-started');
|
|
13
13
|
let [subscription, setSubscription] = useState(null);
|
|
14
14
|
let [jobs, setJobs] = useState([]);
|
|
@@ -26,7 +26,7 @@ export function CreateProject({ args , workspace }) {
|
|
|
26
26
|
isComplete: !!args.options.template
|
|
27
27
|
}
|
|
28
28
|
}));
|
|
29
|
-
let { exit
|
|
29
|
+
let { exit } = useProgram();
|
|
30
30
|
useEffect(()=>{
|
|
31
31
|
if (Object.entries(createProjectInputResult).every(([, result])=>result.isComplete)) {
|
|
32
32
|
setStatus('in-progress');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/create-project/CreateProject.tsx"],"sourcesContent":["import {Header, icons, colors, type CommandArguments, useProgram} from '@jakubmazanec/cli';\nimport chalk from 'chalk';\nimport {Box, Text} from 'ink';\nimport path from 'node:path';\nimport {useEffect, useState} from 'react';\n\nimport {type createProjectCommand} from './createProjectCommand.js';\nimport {CreateProjectInput, type CreateProjectInputResult} from './CreateProjectInput.js';\nimport {runCreateProject} from './runCreateProject.js';\nimport {type Workspace} from '../../workspace.js';\nimport {packageNameToDirectory} from '../internals.js';\n\nconst ONLY_ONE_STAR_REGEXP = /^(?!(.*?\\*){2,}|.*? |\\*$).*?\\*.*$/;\n\nexport type CreateProjectProps = {\n args: CommandArguments<typeof createProjectCommand>;\n workspace: Workspace | Workspace<false>;\n};\n\nexport function CreateProject({args, workspace}: CreateProjectProps) {\n let [status, setStatus] = useState<
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/create-project/CreateProject.tsx"],"sourcesContent":["import {Header, icons, colors, type CommandArguments, useProgram} from '@jakubmazanec/cli';\nimport chalk from 'chalk';\nimport {Box, Text} from 'ink';\nimport path from 'node:path';\nimport {useEffect, useState} from 'react';\n\nimport {type createProjectCommand} from './createProjectCommand.js';\nimport {CreateProjectInput, type CreateProjectInputResult} from './CreateProjectInput.js';\nimport {runCreateProject} from './runCreateProject.js';\nimport {type Workspace} from '../../workspace.js';\nimport {packageNameToDirectory, type CommandStatus} from '../internals.js';\n\nconst ONLY_ONE_STAR_REGEXP = /^(?!(.*?\\*){2,}|.*? |\\*$).*?\\*.*$/;\n\nexport type CreateProjectProps = {\n args: CommandArguments<typeof createProjectCommand>;\n workspace: Workspace | Workspace<false>;\n};\n\nexport function CreateProject({args, workspace}: CreateProjectProps) {\n let [status, setStatus] = useState<CommandStatus>('not-started');\n let [subscription, setSubscription] = useState<ZenObservable.Subscription | null>(null);\n let [jobs, setJobs] = useState<string[]>([]);\n let [createProjectInputResult, setCreateProjectInputResult] = useState<CreateProjectInputResult>(\n () => ({\n projectName: {value: args.options.name ?? '', isComplete: !!args.options.name},\n projectPath: {value: '', isComplete: false},\n templateId: {value: args.options.template ?? '', isComplete: !!args.options.template},\n }),\n );\n let {exit} = useProgram();\n\n useEffect(() => {\n if (Object.entries(createProjectInputResult).every(([, result]) => result.isComplete)) {\n setStatus('in-progress');\n }\n }, [createProjectInputResult]);\n\n useEffect(() => {\n if (status === 'in-progress' && !subscription) {\n let newSubscription = runCreateProject({\n projectPath: createProjectInputResult.projectPath.value,\n templateId: createProjectInputResult.templateId.value,\n projectName: createProjectInputResult.projectName.value,\n workspace,\n args,\n }).subscribe({\n next(value) {\n setJobs((previousJobs) => [...previousJobs, value]);\n },\n error(error) {\n exit(error);\n },\n complete() {\n newSubscription.unsubscribe();\n setStatus('finished');\n },\n });\n setSubscription(newSubscription);\n }\n\n return () => {\n if (subscription) {\n subscription.unsubscribe();\n }\n };\n }, [args, createProjectInputResult, exit, status, subscription, workspace]);\n\n let possiblePaths: Array<{value: string; label: string}> = [];\n\n if (createProjectInputResult.projectName.value) {\n let destinationDirectory = packageNameToDirectory(createProjectInputResult.projectName.value);\n\n if (workspace.projectGlobs) {\n possiblePaths = workspace.projectGlobs\n .filter((projectGlob) => ONLY_ONE_STAR_REGEXP.test(projectGlob))\n .map((projectGlob) => projectGlob.replace(/\\*/, destinationDirectory))\n .map((projectGlob) => path.join(workspace.path, projectGlob))\n .map((projectPath) => ({\n value: projectPath,\n label: path.relative(workspace.path, projectPath).replace('\\\\', '/'),\n }));\n } else {\n possiblePaths = [\n {\n value: workspace.path,\n label: workspace.path,\n },\n ];\n }\n }\n\n return (\n <Box flexDirection=\"column\">\n <Text color={colors.body}>\n {`Creating project in the workspace at ${chalk[colors.info](workspace.path)}.`}\n </Text>\n\n <CreateProjectInput\n rows={{\n projectPath: {\n choices: possiblePaths,\n },\n }}\n values={createProjectInputResult}\n marginTop={1}\n onChange={setCreateProjectInputResult}\n onComplete={setCreateProjectInputResult}\n />\n\n {status === 'in-progress' || status === 'finished' ? (\n <Box marginTop={1} flexDirection=\"column\">\n <Header showSpinner={status === 'in-progress'} icon={icons.success} marginBottom={1}>\n <Text>Creating project...</Text>\n </Header>\n\n {jobs.map((job) => (\n <Text key={job}>{`${icons.info} ${job}`}</Text>\n ))}\n </Box>\n ) : null}\n\n {status === 'finished' ? (\n <Header marginTop={1} icon={icons.success}>\n <Text>Done.</Text>\n </Header>\n ) : null}\n </Box>\n );\n}\n"],"names":["Header","icons","colors","useProgram","chalk","Box","Text","path","useEffect","useState","CreateProjectInput","runCreateProject","packageNameToDirectory","ONLY_ONE_STAR_REGEXP","CreateProject","args","workspace","status","setStatus","subscription","setSubscription","jobs","setJobs","createProjectInputResult","setCreateProjectInputResult","projectName","value","options","name","isComplete","projectPath","templateId","template","exit","Object","entries","every","result","newSubscription","subscribe","next","previousJobs","error","complete","unsubscribe","possiblePaths","destinationDirectory","projectGlobs","filter","projectGlob","test","map","replace","join","label","relative","flexDirection","color","body","info","rows","choices","values","marginTop","onChange","onComplete","showSpinner","icon","success","marginBottom","job"],"mappings":";AAAA,SAAQA,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAyBC,UAAU,QAAO,oBAAoB;AAC3F,OAAOC,WAAW,QAAQ;AAC1B,SAAQC,GAAG,EAAEC,IAAI,QAAO,MAAM;AAC9B,OAAOC,UAAU,YAAY;AAC7B,SAAQC,SAAS,EAAEC,QAAQ,QAAO,QAAQ;AAG1C,SAAQC,kBAAkB,QAAsC,0BAA0B;AAC1F,SAAQC,gBAAgB,QAAO,wBAAwB;AAEvD,SAAQC,sBAAsB,QAA2B,kBAAkB;AAE3E,MAAMC,uBAAuB;AAO7B,OAAO,SAASC,cAAc,EAACC,IAAI,EAAEC,SAAS,EAAqB;IACjE,IAAI,CAACC,QAAQC,UAAU,GAAGT,SAAwB;IAClD,IAAI,CAACU,cAAcC,gBAAgB,GAAGX,SAA4C;IAClF,IAAI,CAACY,MAAMC,QAAQ,GAAGb,SAAmB,EAAE;IAC3C,IAAI,CAACc,0BAA0BC,4BAA4B,GAAGf,SAC5D,IAAO,CAAA;YACLgB,aAAa;gBAACC,OAAOX,KAAKY,OAAO,CAACC,IAAI,IAAI;gBAAIC,YAAY,CAAC,CAACd,KAAKY,OAAO,CAACC,IAAI;YAAA;YAC7EE,aAAa;gBAACJ,OAAO;gBAAIG,YAAY;YAAK;YAC1CE,YAAY;gBAACL,OAAOX,KAAKY,OAAO,CAACK,QAAQ,IAAI;gBAAIH,YAAY,CAAC,CAACd,KAAKY,OAAO,CAACK,QAAQ;YAAA;QACtF,CAAA;IAEF,IAAI,EAACC,IAAI,EAAC,GAAG9B;IAEbK,UAAU;QACR,IAAI0B,OAAOC,OAAO,CAACZ,0BAA0Ba,KAAK,CAAC,CAAC,GAAGC,OAAO,GAAKA,OAAOR,UAAU,GAAG;YACrFX,UAAU;QACZ;IACF,GAAG;QAACK;KAAyB;IAE7Bf,UAAU;QACR,IAAIS,WAAW,iBAAiB,CAACE,cAAc;YAC7C,IAAImB,kBAAkB3B,iBAAiB;gBACrCmB,aAAaP,yBAAyBO,WAAW,CAACJ,KAAK;gBACvDK,YAAYR,yBAAyBQ,UAAU,CAACL,KAAK;gBACrDD,aAAaF,yBAAyBE,WAAW,CAACC,KAAK;gBACvDV;gBACAD;YACF,GAAGwB,SAAS,CAAC;gBACXC,MAAKd,KAAK;oBACRJ,QAAQ,CAACmB,eAAiB;+BAAIA;4BAAcf;yBAAM;gBACpD;gBACAgB,OAAMA,KAAK;oBACTT,KAAKS;gBACP;gBACAC;oBACEL,gBAAgBM,WAAW;oBAC3B1B,UAAU;gBACZ;YACF;YACAE,gBAAgBkB;QAClB;QAEA,OAAO;YACL,IAAInB,cAAc;gBAChBA,aAAayB,WAAW;YAC1B;QACF;IACF,GAAG;QAAC7B;QAAMQ;QAA0BU;QAAMhB;QAAQE;QAAcH;KAAU;IAE1E,IAAI6B,gBAAuD,EAAE;IAE7D,IAAItB,yBAAyBE,WAAW,CAACC,KAAK,EAAE;QAC9C,IAAIoB,uBAAuBlC,uBAAuBW,yBAAyBE,WAAW,CAACC,KAAK;QAE5F,IAAIV,UAAU+B,YAAY,EAAE;YAC1BF,gBAAgB7B,UAAU+B,YAAY,CACnCC,MAAM,CAAC,CAACC,cAAgBpC,qBAAqBqC,IAAI,CAACD,cAClDE,GAAG,CAAC,CAACF,cAAgBA,YAAYG,OAAO,CAAC,MAAMN,uBAC/CK,GAAG,CAAC,CAACF,cAAgB1C,KAAK8C,IAAI,CAACrC,UAAUT,IAAI,EAAE0C,cAC/CE,GAAG,CAAC,CAACrB,cAAiB,CAAA;oBACrBJ,OAAOI;oBACPwB,OAAO/C,KAAKgD,QAAQ,CAACvC,UAAUT,IAAI,EAAEuB,aAAasB,OAAO,CAAC,MAAM;gBAClE,CAAA;QACJ,OAAO;YACLP,gBAAgB;gBACd;oBACEnB,OAAOV,UAAUT,IAAI;oBACrB+C,OAAOtC,UAAUT,IAAI;gBACvB;aACD;QACH;IACF;IAEA,qBACE,MAACF;QAAImD,eAAc;;0BACjB,KAAClD;gBAAKmD,OAAOvD,OAAOwD,IAAI;0BACrB,CAAC,qCAAqC,EAAEtD,KAAK,CAACF,OAAOyD,IAAI,CAAC,CAAC3C,UAAUT,IAAI,EAAE,CAAC,CAAC;;0BAGhF,KAACG;gBACCkD,MAAM;oBACJ9B,aAAa;wBACX+B,SAAShB;oBACX;gBACF;gBACAiB,QAAQvC;gBACRwC,WAAW;gBACXC,UAAUxC;gBACVyC,YAAYzC;;YAGbP,WAAW,iBAAiBA,WAAW,2BACtC,MAACZ;gBAAI0D,WAAW;gBAAGP,eAAc;;kCAC/B,KAACxD;wBAAOkE,aAAajD,WAAW;wBAAekD,MAAMlE,MAAMmE,OAAO;wBAAEC,cAAc;kCAChF,cAAA,KAAC/D;sCAAK;;;oBAGPe,KAAK8B,GAAG,CAAC,CAACmB,oBACT,KAAChE;sCAAgB,CAAC,EAAEL,MAAM0D,IAAI,CAAC,CAAC,EAAEW,IAAI,CAAC;2BAA5BA;;iBAGb;YAEHrD,WAAW,2BACV,KAACjB;gBAAO+D,WAAW;gBAAGI,MAAMlE,MAAMmE,OAAO;0BACvC,cAAA,KAAC9D;8BAAK;;iBAEN;;;AAGV"}
|
|
@@ -17,7 +17,7 @@ export const CreateProjectInput = createForm({
|
|
|
17
17
|
label: 'What is the project name?',
|
|
18
18
|
validate: (value)=>{
|
|
19
19
|
if (!PROJECT_NAME_ID_REGEXP.test(value)) {
|
|
20
|
-
throw new Error('Project name can
|
|
20
|
+
throw new Error('Project name can contain only lowercase letters, numbers, hyphen, @, dot or /.');
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/create-project/CreateProjectInput.ts"],"sourcesContent":["import {type FormResult, createForm} from '@jakubmazanec/cli';\n\nconst TEMPLATE_ID_REGEXP = /^.+:.+$/;\nconst PROJECT_NAME_ID_REGEXP = /^[\\d./@a-z-]+$/;\n\nexport const CreateProjectInput = createForm({\n rows: {\n templateId: {\n type: 'text',\n label: 'What template do you want to use?',\n validate: (value: string) => {\n if (!TEMPLATE_ID_REGEXP.test(value)) {\n throw new Error(\n 'Template ID must consist of a module ID and a template name separated by a colon.',\n );\n }\n },\n },\n projectName: {\n type: 'text',\n label: 'What is the project name?',\n validate: (value: string) => {\n if (!PROJECT_NAME_ID_REGEXP.test(value)) {\n throw new Error(\n 'Project name can
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/create-project/CreateProjectInput.ts"],"sourcesContent":["import {type FormResult, createForm} from '@jakubmazanec/cli';\n\nconst TEMPLATE_ID_REGEXP = /^.+:.+$/;\nconst PROJECT_NAME_ID_REGEXP = /^[\\d./@a-z-]+$/;\n\nexport const CreateProjectInput = createForm({\n rows: {\n templateId: {\n type: 'text',\n label: 'What template do you want to use?',\n validate: (value: string) => {\n if (!TEMPLATE_ID_REGEXP.test(value)) {\n throw new Error(\n 'Template ID must consist of a module ID and a template name separated by a colon.',\n );\n }\n },\n },\n projectName: {\n type: 'text',\n label: 'What is the project name?',\n validate: (value: string) => {\n if (!PROJECT_NAME_ID_REGEXP.test(value)) {\n throw new Error(\n 'Project name can contain only lowercase letters, numbers, hyphen, @, dot or /.',\n );\n }\n },\n },\n projectPath: {\n type: 'select',\n label: 'What is the project location?',\n },\n },\n});\n\nexport type CreateProjectInputResult = FormResult<typeof CreateProjectInput>;\n"],"names":["createForm","TEMPLATE_ID_REGEXP","PROJECT_NAME_ID_REGEXP","CreateProjectInput","rows","templateId","type","label","validate","value","test","Error","projectName","projectPath"],"mappings":"AAAA,SAAyBA,UAAU,QAAO,oBAAoB;AAE9D,MAAMC,qBAAqB;AAC3B,MAAMC,yBAAyB;AAE/B,OAAO,MAAMC,qBAAqBH,WAAW;IAC3CI,MAAM;QACJC,YAAY;YACVC,MAAM;YACNC,OAAO;YACPC,UAAU,CAACC;gBACT,IAAI,CAACR,mBAAmBS,IAAI,CAACD,QAAQ;oBACnC,MAAM,IAAIE,MACR;gBAEJ;YACF;QACF;QACAC,aAAa;YACXN,MAAM;YACNC,OAAO;YACPC,UAAU,CAACC;gBACT,IAAI,CAACP,uBAAuBQ,IAAI,CAACD,QAAQ;oBACvC,MAAM,IAAIE,MACR;gBAEJ;YACF;QACF;QACAE,aAAa;YACXP,MAAM;YACNC,OAAO;QACT;IACF;AACF,GAAG"}
|
|
@@ -5,10 +5,9 @@ import { CreateProject } from './CreateProject.js';
|
|
|
5
5
|
import { Workspace } from '../../workspace.js';
|
|
6
6
|
export const createProjectCommand = new Command('create project', async (args, program)=>{
|
|
7
7
|
let targetPath = path.resolve(process.cwd(), args.options.path ?? '');
|
|
8
|
-
let workspace = await Workspace.findAndRead(targetPath
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
8
|
+
let workspace = await Workspace.findAndRead(targetPath, {
|
|
9
|
+
throwIfNotFound: true
|
|
10
|
+
});
|
|
12
11
|
await program.renderElement(/*#__PURE__*/ _jsx(CreateProject, {
|
|
13
12
|
args: args,
|
|
14
13
|
workspace: workspace
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/create-project/createProjectCommand.tsx"],"sourcesContent":["import {Command} from '@jakubmazanec/cli';\nimport path from 'node:path';\n\nimport {CreateProject} from './CreateProject.js';\nimport {Workspace} from '../../workspace.js';\n\nexport const createProjectCommand = new Command(\n 'create project',\n async (args, program) => {\n let targetPath = path.resolve(process.cwd(), args.options.path ?? '');\n let workspace = await Workspace.findAndRead(targetPath
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/create-project/createProjectCommand.tsx"],"sourcesContent":["import {Command} from '@jakubmazanec/cli';\nimport path from 'node:path';\n\nimport {CreateProject} from './CreateProject.js';\nimport {Workspace} from '../../workspace.js';\n\nexport const createProjectCommand = new Command(\n 'create project',\n async (args, program) => {\n let targetPath = path.resolve(process.cwd(), args.options.path ?? '');\n let workspace = await Workspace.findAndRead(targetPath, {throwIfNotFound: true});\n\n await program.renderElement(<CreateProject args={args} workspace={workspace} />);\n },\n {\n description: 'Creates a new project in an existing workspace.',\n options: {\n path: {\n type: 'string',\n },\n template: {\n type: 'string',\n },\n name: {\n type: 'string',\n },\n },\n },\n);\n"],"names":["Command","path","CreateProject","Workspace","createProjectCommand","args","program","targetPath","resolve","process","cwd","options","workspace","findAndRead","throwIfNotFound","renderElement","description","type","template","name"],"mappings":";AAAA,SAAQA,OAAO,QAAO,oBAAoB;AAC1C,OAAOC,UAAU,YAAY;AAE7B,SAAQC,aAAa,QAAO,qBAAqB;AACjD,SAAQC,SAAS,QAAO,qBAAqB;AAE7C,OAAO,MAAMC,uBAAuB,IAAIJ,QACtC,kBACA,OAAOK,MAAMC;IACX,IAAIC,aAAaN,KAAKO,OAAO,CAACC,QAAQC,GAAG,IAAIL,KAAKM,OAAO,CAACV,IAAI,IAAI;IAClE,IAAIW,YAAY,MAAMT,UAAUU,WAAW,CAACN,YAAY;QAACO,iBAAiB;IAAI;IAE9E,MAAMR,QAAQS,aAAa,eAAC,KAACb;QAAcG,MAAMA;QAAMO,WAAWA;;AACpE,GACA;IACEI,aAAa;IACbL,SAAS;QACPV,MAAM;YACJgB,MAAM;QACR;QACAC,UAAU;YACRD,MAAM;QACR;QACAE,MAAM;YACJF,MAAM;QACR;IACF;AACF,GACA"}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import { isEmptyDirectory } from '@jakubmazanec/fs-utils';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import path from 'node:path';
|
|
4
1
|
import Observable from 'zen-observable';
|
|
5
|
-
export function runCreateProject({ projectPath
|
|
2
|
+
export function runCreateProject({ projectPath, templateId, projectName, workspace, args }) {
|
|
6
3
|
return new Observable((observer)=>{
|
|
7
4
|
(async ()=>{
|
|
8
|
-
observer.next('
|
|
9
|
-
let resolvedProjectPath = path.resolve(projectPath);
|
|
10
|
-
// check if path is ok
|
|
11
|
-
await fs.ensureDir(resolvedProjectPath);
|
|
12
|
-
let isProjectPathEmpty = await isEmptyDirectory(resolvedProjectPath);
|
|
13
|
-
if (!isProjectPathEmpty) {
|
|
14
|
-
throw new Error(`Directory "${resolvedProjectPath}" must be empty`);
|
|
15
|
-
}
|
|
16
|
-
// create new project
|
|
5
|
+
observer.next('Creating files');
|
|
17
6
|
let project = await workspace.createProject({
|
|
18
|
-
projectPath
|
|
7
|
+
projectPath,
|
|
19
8
|
projectName,
|
|
20
9
|
templateId,
|
|
21
10
|
args
|
|
22
11
|
});
|
|
12
|
+
observer.next('Updating the new project');
|
|
23
13
|
await project.update({
|
|
24
14
|
args
|
|
25
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/create-project/runCreateProject.ts"],"sourcesContent":["import {type CommandArguments} from '@jakubmazanec/cli';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/create-project/runCreateProject.ts"],"sourcesContent":["import {type CommandArguments} from '@jakubmazanec/cli';\nimport Observable from 'zen-observable';\n\nimport {type createProjectCommand} from './createProjectCommand.js';\nimport {type Workspace} from '../../workspace.js';\n\nexport type CreateProjectOptions = {\n projectPath: string;\n projectName: string;\n templateId: string;\n workspace: Workspace | Workspace<false>;\n args: CommandArguments<typeof createProjectCommand>;\n};\n\nexport type CreateProjectStatus = string;\n\nexport function runCreateProject({\n projectPath,\n templateId,\n projectName,\n workspace,\n args,\n}: CreateProjectOptions) {\n return new Observable<CreateProjectStatus>((observer) => {\n (async () => {\n observer.next('Creating files');\n\n let project = await workspace.createProject({\n projectPath,\n projectName,\n templateId,\n args,\n });\n\n observer.next('Updating the new project');\n\n await project.update({args});\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error) => {\n observer.error(error);\n });\n });\n}\n"],"names":["Observable","runCreateProject","projectPath","templateId","projectName","workspace","args","observer","next","project","createProject","update","then","complete","catch","error"],"mappings":"AACA,OAAOA,gBAAgB,iBAAiB;AAexC,OAAO,SAASC,iBAAiB,EAC/BC,WAAW,EACXC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,IAAI,EACiB;IACrB,OAAO,IAAIN,WAAgC,CAACO;QACzC,CAAA;YACCA,SAASC,IAAI,CAAC;YAEd,IAAIC,UAAU,MAAMJ,UAAUK,aAAa,CAAC;gBAC1CR;gBACAE;gBACAD;gBACAG;YACF;YAEAC,SAASC,IAAI,CAAC;YAEd,MAAMC,QAAQE,MAAM,CAAC;gBAACL;YAAI;QAC5B,CAAA,IACGM,IAAI,CAAC;YACJL,SAASM,QAAQ;QACnB,GACCC,KAAK,CAAC,CAACC;YACNR,SAASQ,KAAK,CAACA;QACjB;IACJ;AACF"}
|
|
@@ -2,6 +2,5 @@ import { type CommandArguments } from '@jakubmazanec/cli';
|
|
|
2
2
|
import { type createWorkspaceCommand } from './createWorkspaceCommand.js';
|
|
3
3
|
export type CreateWorkspaceProps = {
|
|
4
4
|
args: CommandArguments<typeof createWorkspaceCommand>;
|
|
5
|
-
path: string;
|
|
6
5
|
};
|
|
7
|
-
export declare function CreateWorkspace({ args
|
|
6
|
+
export declare function CreateWorkspace({ args }: CreateWorkspaceProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,10 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Header, icons, colors, useProgram } from '@jakubmazanec/cli';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { Box, Text } from 'ink';
|
|
5
|
+
import path from 'node:path';
|
|
5
6
|
import { useEffect, useState } from 'react';
|
|
6
7
|
import { CreateWorkspaceInput } from './CreateWorkspaceInput.js';
|
|
7
8
|
import { runCreateWorkspace } from './runCreateWorkspace.js';
|
|
8
|
-
export function CreateWorkspace({ args
|
|
9
|
+
export function CreateWorkspace({ args }) {
|
|
9
10
|
let [status, setStatus] = useState('not-started');
|
|
10
11
|
let [subscription, setSubscription] = useState(null);
|
|
11
12
|
let [jobs, setJobs] = useState([]);
|
|
@@ -15,7 +16,8 @@ export function CreateWorkspace({ args , path }) {
|
|
|
15
16
|
isComplete: !!args.options.template
|
|
16
17
|
}
|
|
17
18
|
}));
|
|
18
|
-
let { exit
|
|
19
|
+
let { exit } = useProgram();
|
|
20
|
+
let workspacePath = path.resolve(process.cwd(), args.options.path ?? '');
|
|
19
21
|
useEffect(()=>{
|
|
20
22
|
if (Object.entries(createWorkspaceInputResult).every(([, result])=>result.isComplete)) {
|
|
21
23
|
setStatus('in-progress');
|
|
@@ -26,7 +28,7 @@ export function CreateWorkspace({ args , path }) {
|
|
|
26
28
|
useEffect(()=>{
|
|
27
29
|
if (status === 'in-progress' && !subscription) {
|
|
28
30
|
let newSubscription = runCreateWorkspace({
|
|
29
|
-
workspacePath
|
|
31
|
+
workspacePath,
|
|
30
32
|
templateId: createWorkspaceInputResult.templateId.value,
|
|
31
33
|
args
|
|
32
34
|
}).subscribe({
|
|
@@ -53,11 +55,11 @@ export function CreateWorkspace({ args , path }) {
|
|
|
53
55
|
};
|
|
54
56
|
}, [
|
|
55
57
|
createWorkspaceInputResult,
|
|
56
|
-
path,
|
|
57
58
|
status,
|
|
58
59
|
subscription,
|
|
59
60
|
args,
|
|
60
|
-
exit
|
|
61
|
+
exit,
|
|
62
|
+
workspacePath
|
|
61
63
|
]);
|
|
62
64
|
return /*#__PURE__*/ _jsxs(Box, {
|
|
63
65
|
flexDirection: "column",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/create-workspace/CreateWorkspace.tsx"],"sourcesContent":["import {Header, icons, colors, type CommandArguments, useProgram} from '@jakubmazanec/cli';\nimport chalk from 'chalk';\nimport {Box, Text} from 'ink';\nimport {useEffect, useState} from 'react';\n\nimport {type createWorkspaceCommand} from './createWorkspaceCommand.js';\nimport {CreateWorkspaceInput, type CreateWorkspaceInputResult} from './CreateWorkspaceInput.js';\nimport {runCreateWorkspace} from './runCreateWorkspace.js';\n\nexport type CreateWorkspaceProps = {\n args: CommandArguments<typeof createWorkspaceCommand>;\n
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/create-workspace/CreateWorkspace.tsx"],"sourcesContent":["import {Header, icons, colors, type CommandArguments, useProgram} from '@jakubmazanec/cli';\nimport chalk from 'chalk';\nimport {Box, Text} from 'ink';\nimport path from 'node:path';\nimport {useEffect, useState} from 'react';\n\nimport {type createWorkspaceCommand} from './createWorkspaceCommand.js';\nimport {CreateWorkspaceInput, type CreateWorkspaceInputResult} from './CreateWorkspaceInput.js';\nimport {runCreateWorkspace} from './runCreateWorkspace.js';\nimport {type CommandStatus} from '../internals.js';\n\nexport type CreateWorkspaceProps = {\n args: CommandArguments<typeof createWorkspaceCommand>;\n};\n\nexport function CreateWorkspace({args}: CreateWorkspaceProps) {\n let [status, setStatus] = useState<CommandStatus>('not-started');\n let [subscription, setSubscription] = useState<ZenObservable.Subscription | null>(null);\n let [jobs, setJobs] = useState<string[]>([]);\n let [createWorkspaceInputResult, setCreateWorkspaceInputResult] =\n useState<CreateWorkspaceInputResult>(() => ({\n templateId: {value: args.options.template ?? '', isComplete: !!args.options.template},\n }));\n let {exit} = useProgram();\n let workspacePath = path.resolve(process.cwd(), args.options.path ?? '');\n\n useEffect(() => {\n if (Object.entries(createWorkspaceInputResult).every(([, result]) => result.isComplete)) {\n setStatus('in-progress');\n }\n }, [createWorkspaceInputResult]);\n\n useEffect(() => {\n if (status === 'in-progress' && !subscription) {\n let newSubscription = runCreateWorkspace({\n workspacePath,\n templateId: createWorkspaceInputResult.templateId.value,\n args,\n }).subscribe({\n next(value) {\n setJobs((previousJobs) => [...previousJobs, value]);\n },\n error(error) {\n exit(error);\n },\n complete() {\n newSubscription.unsubscribe();\n setStatus('finished');\n },\n });\n\n setSubscription(newSubscription);\n }\n\n return () => {\n if (subscription) {\n subscription.unsubscribe();\n }\n };\n }, [createWorkspaceInputResult, status, subscription, args, exit, workspacePath]);\n\n return (\n <Box flexDirection=\"column\">\n <Text>{`Creating workspace at ${chalk[colors.highlighted](path)}.`}</Text>\n\n <CreateWorkspaceInput\n values={createWorkspaceInputResult}\n marginTop={1}\n onChange={setCreateWorkspaceInputResult}\n onComplete={setCreateWorkspaceInputResult}\n />\n\n {status === 'in-progress' || status === 'finished' ? (\n <Box marginTop={1} flexDirection=\"column\">\n <Header showSpinner={status === 'in-progress'} icon={icons.success} marginBottom={1}>\n <Text>Creating workspace...</Text>\n </Header>\n\n {jobs.map((job) => (\n <Text key={job}>{`${icons.info} ${job}`}</Text>\n ))}\n </Box>\n ) : null}\n\n {status === 'finished' ? (\n <Header marginTop={1} icon={icons.success}>\n <Text>Done.</Text>\n </Header>\n ) : null}\n </Box>\n );\n}\n"],"names":["Header","icons","colors","useProgram","chalk","Box","Text","path","useEffect","useState","CreateWorkspaceInput","runCreateWorkspace","CreateWorkspace","args","status","setStatus","subscription","setSubscription","jobs","setJobs","createWorkspaceInputResult","setCreateWorkspaceInputResult","templateId","value","options","template","isComplete","exit","workspacePath","resolve","process","cwd","Object","entries","every","result","newSubscription","subscribe","next","previousJobs","error","complete","unsubscribe","flexDirection","highlighted","values","marginTop","onChange","onComplete","showSpinner","icon","success","marginBottom","map","job","info"],"mappings":";AAAA,SAAQA,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAyBC,UAAU,QAAO,oBAAoB;AAC3F,OAAOC,WAAW,QAAQ;AAC1B,SAAQC,GAAG,EAAEC,IAAI,QAAO,MAAM;AAC9B,OAAOC,UAAU,YAAY;AAC7B,SAAQC,SAAS,EAAEC,QAAQ,QAAO,QAAQ;AAG1C,SAAQC,oBAAoB,QAAwC,4BAA4B;AAChG,SAAQC,kBAAkB,QAAO,0BAA0B;AAO3D,OAAO,SAASC,gBAAgB,EAACC,IAAI,EAAuB;IAC1D,IAAI,CAACC,QAAQC,UAAU,GAAGN,SAAwB;IAClD,IAAI,CAACO,cAAcC,gBAAgB,GAAGR,SAA4C;IAClF,IAAI,CAACS,MAAMC,QAAQ,GAAGV,SAAmB,EAAE;IAC3C,IAAI,CAACW,4BAA4BC,8BAA8B,GAC7DZ,SAAqC,IAAO,CAAA;YAC1Ca,YAAY;gBAACC,OAAOV,KAAKW,OAAO,CAACC,QAAQ,IAAI;gBAAIC,YAAY,CAAC,CAACb,KAAKW,OAAO,CAACC,QAAQ;YAAA;QACtF,CAAA;IACF,IAAI,EAACE,IAAI,EAAC,GAAGxB;IACb,IAAIyB,gBAAgBrB,KAAKsB,OAAO,CAACC,QAAQC,GAAG,IAAIlB,KAAKW,OAAO,CAACjB,IAAI,IAAI;IAErEC,UAAU;QACR,IAAIwB,OAAOC,OAAO,CAACb,4BAA4Bc,KAAK,CAAC,CAAC,GAAGC,OAAO,GAAKA,OAAOT,UAAU,GAAG;YACvFX,UAAU;QACZ;IACF,GAAG;QAACK;KAA2B;IAE/BZ,UAAU;QACR,IAAIM,WAAW,iBAAiB,CAACE,cAAc;YAC7C,IAAIoB,kBAAkBzB,mBAAmB;gBACvCiB;gBACAN,YAAYF,2BAA2BE,UAAU,CAACC,KAAK;gBACvDV;YACF,GAAGwB,SAAS,CAAC;gBACXC,MAAKf,KAAK;oBACRJ,QAAQ,CAACoB,eAAiB;+BAAIA;4BAAchB;yBAAM;gBACpD;gBACAiB,OAAMA,KAAK;oBACTb,KAAKa;gBACP;gBACAC;oBACEL,gBAAgBM,WAAW;oBAC3B3B,UAAU;gBACZ;YACF;YAEAE,gBAAgBmB;QAClB;QAEA,OAAO;YACL,IAAIpB,cAAc;gBAChBA,aAAa0B,WAAW;YAC1B;QACF;IACF,GAAG;QAACtB;QAA4BN;QAAQE;QAAcH;QAAMc;QAAMC;KAAc;IAEhF,qBACE,MAACvB;QAAIsC,eAAc;;0BACjB,KAACrC;0BAAM,CAAC,sBAAsB,EAAEF,KAAK,CAACF,OAAO0C,WAAW,CAAC,CAACrC,MAAM,CAAC,CAAC;;0BAElE,KAACG;gBACCmC,QAAQzB;gBACR0B,WAAW;gBACXC,UAAU1B;gBACV2B,YAAY3B;;YAGbP,WAAW,iBAAiBA,WAAW,2BACtC,MAACT;gBAAIyC,WAAW;gBAAGH,eAAc;;kCAC/B,KAAC3C;wBAAOiD,aAAanC,WAAW;wBAAeoC,MAAMjD,MAAMkD,OAAO;wBAAEC,cAAc;kCAChF,cAAA,KAAC9C;sCAAK;;;oBAGPY,KAAKmC,GAAG,CAAC,CAACC,oBACT,KAAChD;sCAAgB,CAAC,EAAEL,MAAMsD,IAAI,CAAC,CAAC,EAAED,IAAI,CAAC;2BAA5BA;;iBAGb;YAEHxC,WAAW,2BACV,KAACd;gBAAO8C,WAAW;gBAAGI,MAAMjD,MAAMkD,OAAO;0BACvC,cAAA,KAAC7C;8BAAK;;iBAEN;;;AAGV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/create-workspace/CreateWorkspaceInput.ts"],"sourcesContent":["import {type FormResult, createForm} from '@jakubmazanec/cli';\n\nconst TEMPLATE_ID_REGEXP = /^.+:.+$/;\n\nexport const CreateWorkspaceInput = createForm({\n rows: {\n templateId: {\n type: 'text',\n label: 'Enter template ID:',\n validate: (value: string) => {\n if (!TEMPLATE_ID_REGEXP.test(value)) {\n throw new Error(\n 'Template ID must consist of a module ID and a template name separated by a colon.',\n );\n }\n },\n },\n },\n});\n\nexport type CreateWorkspaceInputResult = FormResult<typeof CreateWorkspaceInput>;\n"],"names":["createForm","TEMPLATE_ID_REGEXP","CreateWorkspaceInput","rows","templateId","type","label","validate","value","test","Error"],"mappings":"AAAA,SAAyBA,UAAU,QAAO,oBAAoB;AAE9D,MAAMC,qBAAqB;AAE3B,OAAO,MAAMC,uBAAuBF,WAAW;IAC7CG,MAAM;QACJC,YAAY;YACVC,MAAM;YACNC,OAAO;YACPC,UAAU,CAACC;gBACT,IAAI,CAACP,mBAAmBQ,
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/create-workspace/CreateWorkspaceInput.ts"],"sourcesContent":["import {type FormResult, createForm} from '@jakubmazanec/cli';\n\nconst TEMPLATE_ID_REGEXP = /^.+:.+$/;\n\nexport const CreateWorkspaceInput = createForm({\n rows: {\n templateId: {\n type: 'text',\n label: 'Enter template ID:',\n validate: (value: string) => {\n if (!TEMPLATE_ID_REGEXP.test(value)) {\n throw new Error(\n 'Template ID must consist of a module ID and a template name separated by a colon.',\n );\n }\n },\n },\n },\n});\n\nexport type CreateWorkspaceInputResult = FormResult<typeof CreateWorkspaceInput>;\n"],"names":["createForm","TEMPLATE_ID_REGEXP","CreateWorkspaceInput","rows","templateId","type","label","validate","value","test","Error"],"mappings":"AAAA,SAAyBA,UAAU,QAAO,oBAAoB;AAE9D,MAAMC,qBAAqB;AAE3B,OAAO,MAAMC,uBAAuBF,WAAW;IAC7CG,MAAM;QACJC,YAAY;YACVC,MAAM;YACNC,OAAO;YACPC,UAAU,CAACC;gBACT,IAAI,CAACP,mBAAmBQ,IAAI,CAACD,QAAQ;oBACnC,MAAM,IAAIE,MACR;gBAEJ;YACF;QACF;IACF;AACF,GAAG"}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Command } from '@jakubmazanec/cli';
|
|
3
|
-
import { isEmptyDirectory } from '@jakubmazanec/fs-utils';
|
|
4
|
-
import fs from 'fs-extra';
|
|
5
|
-
import path from 'node:path';
|
|
6
3
|
import { CreateWorkspace } from './CreateWorkspace.js';
|
|
7
4
|
export const createWorkspaceCommand = new Command('create workspace', async (args, program)=>{
|
|
8
|
-
let workspacePath = path.resolve(process.cwd(), args.options.path ?? '');
|
|
9
|
-
await fs.ensureDir(workspacePath);
|
|
10
|
-
let isWorkspacePathEmpty = await isEmptyDirectory(workspacePath);
|
|
11
|
-
if (!isWorkspacePathEmpty) {
|
|
12
|
-
throw new Error(`Directory "${workspacePath}" must be empty`);
|
|
13
|
-
}
|
|
14
5
|
await program.renderElement(/*#__PURE__*/ _jsx(CreateWorkspace, {
|
|
15
|
-
args: args
|
|
16
|
-
path: workspacePath
|
|
6
|
+
args: args
|
|
17
7
|
}));
|
|
18
8
|
}, {
|
|
19
9
|
description: 'Creates a new workspacee.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/create-workspace/createWorkspaceCommand.tsx"],"sourcesContent":["import {Command} from '@jakubmazanec/cli';\
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/create-workspace/createWorkspaceCommand.tsx"],"sourcesContent":["import {Command} from '@jakubmazanec/cli';\n\nimport {CreateWorkspace} from './CreateWorkspace.js';\n\nexport const createWorkspaceCommand = new Command(\n 'create workspace',\n async (args, program) => {\n await program.renderElement(<CreateWorkspace args={args} />);\n },\n {\n description: 'Creates a new workspacee.',\n options: {\n path: {\n type: 'string',\n },\n template: {\n type: 'string',\n },\n },\n },\n);\n"],"names":["Command","CreateWorkspace","createWorkspaceCommand","args","program","renderElement","description","options","path","type","template"],"mappings":";AAAA,SAAQA,OAAO,QAAO,oBAAoB;AAE1C,SAAQC,eAAe,QAAO,uBAAuB;AAErD,OAAO,MAAMC,yBAAyB,IAAIF,QACxC,oBACA,OAAOG,MAAMC;IACX,MAAMA,QAAQC,aAAa,eAAC,KAACJ;QAAgBE,MAAMA;;AACrD,GACA;IACEG,aAAa;IACbC,SAAS;QACPC,MAAM;YACJC,MAAM;QACR;QACAC,UAAU;YACRD,MAAM;QACR;IACF;AACF,GACA"}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import { isEmptyDirectory } from '@jakubmazanec/fs-utils';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import path from 'node:path';
|
|
4
1
|
import Observable from 'zen-observable';
|
|
5
2
|
import { Workspace } from '../../workspace.js';
|
|
6
|
-
export function runCreateWorkspace({ workspacePath
|
|
3
|
+
export function runCreateWorkspace({ workspacePath, templateId, args }) {
|
|
7
4
|
return new Observable((observer)=>{
|
|
8
5
|
(async ()=>{
|
|
9
|
-
observer.next('
|
|
10
|
-
let resolvedWorkspacePath = path.resolve(workspacePath);
|
|
11
|
-
await fs.ensureDir(resolvedWorkspacePath);
|
|
12
|
-
let isWorkspacePathEmpty = await isEmptyDirectory(resolvedWorkspacePath);
|
|
13
|
-
if (!isWorkspacePathEmpty) {
|
|
14
|
-
throw new Error(`Directory "${resolvedWorkspacePath}" must be empty`);
|
|
15
|
-
}
|
|
16
|
-
// create new workspace
|
|
6
|
+
observer.next('Creating files');
|
|
17
7
|
let workspace = await Workspace.create({
|
|
18
8
|
args,
|
|
19
|
-
path:
|
|
9
|
+
path: workspacePath,
|
|
20
10
|
templateId
|
|
21
11
|
});
|
|
12
|
+
observer.next('Updating the new workspace');
|
|
22
13
|
await workspace.update({
|
|
23
14
|
args
|
|
24
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/create-workspace/runCreateWorkspace.ts"],"sourcesContent":["import {type CommandArguments} from '@jakubmazanec/cli';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/create-workspace/runCreateWorkspace.ts"],"sourcesContent":["import {type CommandArguments} from '@jakubmazanec/cli';\nimport Observable from 'zen-observable';\n\nimport {type createWorkspaceCommand} from './createWorkspaceCommand.js';\nimport {Workspace} from '../../workspace.js';\n\nexport type CreateWorkspaceOptions = {\n workspacePath: string;\n templateId: string;\n args: CommandArguments<typeof createWorkspaceCommand>;\n};\n\nexport type CreateWorkspaceStatus = string;\n\nexport function runCreateWorkspace({workspacePath, templateId, args}: CreateWorkspaceOptions) {\n return new Observable<CreateWorkspaceStatus>((observer) => {\n (async () => {\n observer.next('Creating files');\n\n let workspace = await Workspace.create({\n args,\n path: workspacePath,\n templateId,\n });\n\n observer.next('Updating the new workspace');\n\n await workspace.update({args});\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error) => {\n observer.error(error);\n });\n });\n}\n"],"names":["Observable","Workspace","runCreateWorkspace","workspacePath","templateId","args","observer","next","workspace","create","path","update","then","complete","catch","error"],"mappings":"AACA,OAAOA,gBAAgB,iBAAiB;AAGxC,SAAQC,SAAS,QAAO,qBAAqB;AAU7C,OAAO,SAASC,mBAAmB,EAACC,aAAa,EAAEC,UAAU,EAAEC,IAAI,EAAyB;IAC1F,OAAO,IAAIL,WAAkC,CAACM;QAC3C,CAAA;YACCA,SAASC,IAAI,CAAC;YAEd,IAAIC,YAAY,MAAMP,UAAUQ,MAAM,CAAC;gBACrCJ;gBACAK,MAAMP;gBACNC;YACF;YAEAE,SAASC,IAAI,CAAC;YAEd,MAAMC,UAAUG,MAAM,CAAC;gBAACN;YAAI;QAC9B,CAAA,IACGO,IAAI,CAAC;YACJN,SAASO,QAAQ;QACnB,GACCC,KAAK,CAAC,CAACC;YACNT,SAASS,KAAK,CAACA;QACjB;IACJ;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CommandStatus = 'finished' | 'in-progress' | 'not-started';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/internals/CommandStatus.ts"],"sourcesContent":["export type CommandStatus = 'finished' | 'in-progress' | 'not-started';\n"],"names":[],"mappings":"AAAA,WAAuE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/internals/packageNameToDirectory.ts"],"sourcesContent":["export function packageNameToDirectory(packageName: string): string {\n const packageNameParts = packageName.split('/');\n\n if (packageNameParts.length === 1) {\n return packageNameParts[0] as string;\n }\n\n if (packageNameParts.length > 1 && packageName[0] !== '@') {\n return packageNameParts[0] as string;\n }\n\n return packageNameParts[1] as string;\n}\n"],"names":["packageNameToDirectory","packageName","packageNameParts","split","length"],"mappings":"AAAA,OAAO,SAASA,uBAAuBC,WAAmB;IACxD,MAAMC,mBAAmBD,YAAYE,
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/internals/packageNameToDirectory.ts"],"sourcesContent":["export function packageNameToDirectory(packageName: string): string {\n const packageNameParts = packageName.split('/');\n\n if (packageNameParts.length === 1) {\n return packageNameParts[0] as string;\n }\n\n if (packageNameParts.length > 1 && packageName[0] !== '@') {\n return packageNameParts[0] as string;\n }\n\n return packageNameParts[1] as string;\n}\n"],"names":["packageNameToDirectory","packageName","packageNameParts","split","length"],"mappings":"AAAA,OAAO,SAASA,uBAAuBC,WAAmB;IACxD,MAAMC,mBAAmBD,YAAYE,KAAK,CAAC;IAE3C,IAAID,iBAAiBE,MAAM,KAAK,GAAG;QACjC,OAAOF,gBAAgB,CAAC,EAAE;IAC5B;IAEA,IAAIA,iBAAiBE,MAAM,GAAG,KAAKH,WAAW,CAAC,EAAE,KAAK,KAAK;QACzD,OAAOC,gBAAgB,CAAC,EAAE;IAC5B;IAEA,OAAOA,gBAAgB,CAAC,EAAE;AAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/internals.ts"],"sourcesContent":["export * from './internals/packageNameToDirectory.js';\n"],"names":[],"mappings":"AAAA,cAAc,wCAAwC"}
|
|
1
|
+
{"version":3,"sources":["../../src/commands/internals.ts"],"sourcesContent":["export * from './internals/CommandStatus.js';\nexport * from './internals/packageNameToDirectory.js';\n"],"names":[],"mappings":"AAAA,cAAc,+BAA+B;AAC7C,cAAc,wCAAwC"}
|
|
@@ -4,10 +4,10 @@ import chalk from 'chalk';
|
|
|
4
4
|
import { Box, Text } from 'ink';
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
import { runUpdateWorkspace } from './runUpdateWorkspace.js';
|
|
7
|
-
export function UpdateWorkspace({ workspace
|
|
7
|
+
export function UpdateWorkspace({ workspace, args }) {
|
|
8
8
|
let [isFinished, setIsFinished] = useState(false);
|
|
9
9
|
let [jobs, setJobs] = useState([]);
|
|
10
|
-
let { exit
|
|
10
|
+
let { exit } = useProgram();
|
|
11
11
|
useEffect(()=>{
|
|
12
12
|
let subscription = runUpdateWorkspace({
|
|
13
13
|
workspace,
|
|
@@ -49,7 +49,7 @@ export function UpdateWorkspace({ workspace , args }) {
|
|
|
49
49
|
icon: icons.success,
|
|
50
50
|
marginBottom: 1,
|
|
51
51
|
children: /*#__PURE__*/ _jsx(Text, {
|
|
52
|
-
children: "Updating workspace..."
|
|
52
|
+
children: "Updating workspace and projects..."
|
|
53
53
|
})
|
|
54
54
|
}),
|
|
55
55
|
jobs.map((job)=>/*#__PURE__*/ _jsx(Text, {
|