@jakubmazanec/carson 1.2.1 → 1.2.2-unstable.91147a2
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/build/commands/create-project/CreateProject.js +4 -4
- package/build/commands/create-project/CreateProject.js.map +2 -2
- package/build/commands/create-project/runCreateProject.js.map +2 -2
- package/build/commands/create-workspace/CreateWorkspace.js +4 -4
- package/build/commands/create-workspace/CreateWorkspace.js.map +2 -2
- package/build/commands/create-workspace/runCreateWorkspace.js.map +2 -2
- package/build/commands/update-workspace/UpdateWorkspace.js +3 -3
- package/build/commands/update-workspace/UpdateWorkspace.js.map +2 -2
- package/build/commands/update-workspace/runUpdateWorkspace.js.map +2 -2
- package/build/commands/update-workspace/updateWorkspaceCommand.js +1 -1
- package/build/commands/update-workspace/updateWorkspaceCommand.js.map +2 -2
- package/build/template/TemplateRender.d.ts +2 -2
- package/build/template/applyTemplateRenders.js.map +2 -2
- package/build/workspace/Workspace.d.ts +1 -1
- package/build/workspace/Workspace.js.map +1 -1
- package/build/workspace/WorkspaceDependencies.js.map +2 -2
- package/build/workspace/internals/getRepositoryBranches.js +1 -1
- package/build/workspace/internals/getRepositoryBranches.js.map +2 -2
- package/package.json +10 -10
- package/source/commands/create-project/CreateProject.tsx +5 -5
- package/source/commands/create-project/runCreateProject.ts +1 -1
- package/source/commands/create-workspace/CreateWorkspace.tsx +5 -5
- package/source/commands/create-workspace/runCreateWorkspace.ts +1 -1
- package/source/commands/update-workspace/UpdateWorkspace.tsx +3 -3
- package/source/commands/update-workspace/runUpdateWorkspace.ts +1 -1
- package/source/commands/update-workspace/updateWorkspaceCommand.tsx +1 -1
- package/source/template/TemplateRender.ts +2 -5
- package/source/template/applyTemplateRenders.ts +0 -2
- package/source/workspace/Workspace.ts +7 -7
- package/source/workspace/WorkspaceDependencies.ts +0 -2
- package/source/workspace/internals/getRepositoryBranches.ts +1 -1
|
@@ -95,17 +95,17 @@ export function CreateProject({ args, workspace }) {
|
|
|
95
95
|
choices: possiblePaths
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
|
-
values: createProjectInputResult,
|
|
99
98
|
marginTop: 1,
|
|
99
|
+
values: createProjectInputResult,
|
|
100
100
|
onChange: setCreateProjectInputResult,
|
|
101
101
|
onComplete: setCreateProjectInputResult
|
|
102
102
|
}
|
|
103
103
|
),
|
|
104
|
-
status === "in-progress" || status === "finished" ? /* @__PURE__ */ jsxs(Box, {
|
|
105
|
-
/* @__PURE__ */ jsx(Header, { showSpinner: status === "in-progress",
|
|
104
|
+
status === "in-progress" || status === "finished" ? /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
105
|
+
/* @__PURE__ */ jsx(Header, { icon: icons.success, marginBottom: 1, showSpinner: status === "in-progress", children: /* @__PURE__ */ jsx(Text, { children: "Creating project..." }) }),
|
|
106
106
|
jobs.map((job) => /* @__PURE__ */ jsx(Text, { children: `${icons.info} ${job}` }, job))
|
|
107
107
|
] }) : null,
|
|
108
|
-
status === "finished" ? /* @__PURE__ */ jsx(Header, {
|
|
108
|
+
status === "finished" ? /* @__PURE__ */ jsx(Header, { icon: icons.success, marginTop: 1, children: /* @__PURE__ */ jsx(Text, { children: "Done." }) }) : null
|
|
109
109
|
] });
|
|
110
110
|
}
|
|
111
111
|
//# sourceMappingURL=CreateProject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../source/commands/create-project/CreateProject.tsx"],
|
|
4
|
-
"sourcesContent": ["import {colors, type CommandArguments, Header, icons, 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 Workspace} from '../../workspace.js';\nimport {type CommandStatus, packageNameToDirectory} from '../internals.js';\nimport {type createProjectCommand} from './createProjectCommand.js';\nimport {CreateProjectInput, type CreateProjectInputResult} from './CreateProjectInput.js';\nimport {runCreateProject} from './runCreateProject.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
|
|
5
|
-
"mappings": ";AAiHM,cAiBE,YAjBF;AAjHN,SAAQ,QAA+B,QAAQ,OAAO,kBAAiB;AACvE,OAAO,WAAW;AAClB,SAAQ,KAAK,YAAW;AACxB,OAAO,UAAU;AACjB,SAAQ,WAAW,gBAAe;AAGlC,SAA4B,8BAA6B;AAEzD,SAAQ,0BAAwD;AAChE,SAAQ,wBAAuB;AAE/B,MAAM,uBAAuB;AAOtB,gBAAS,cAAc,EAAC,MAAM,UAAS,GAAuB;AACnE,MAAI,CAAC,QAAQ,SAAS,IAAI,SAAwB,aAAa;AAC/D,MAAI,CAAC,cAAc,eAAe,IAAI,SAA4C,IAAI;AACtF,MAAI,CAAC,MAAM,OAAO,IAAI,SAAmB,CAAC,CAAC;AAC3C,MAAI,CAAC,0BAA0B,2BAA2B,IAAI;AAAA,IAC5D,OAAO;AAAA,MACL,aAAa,EAAC,OAAO,KAAK,QAAQ,QAAQ,IAAI,YAAY,CAAC,CAAC,KAAK,QAAQ,KAAI;AAAA,MAC7E,aAAa,EAAC,OAAO,IAAI,YAAY,MAAK;AAAA,MAC1C,YAAY,EAAC,OAAO,KAAK,QAAQ,YAAY,IAAI,YAAY,CAAC,CAAC,KAAK,QAAQ,SAAQ;AAAA,IACtF;AAAA,EACF;AACA,MAAI,EAAC,KAAI,IAAI,WAAW;AAExB,YAAU,MAAM;AACd,QAAI,OAAO,QAAQ,wBAAwB,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,MAAM,OAAO,UAAU,GAAG;AACrF,gBAAU,aAA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CAAC,gBAAgB,CAAC,qBAAqB,KAAK,WAAW,CAAC,EAC/D,IAAI,CAAC,gBAAgB,KAAK,KAAK,UAAU,MAAM,WAAW,CAAC,EAC3D,IAAI,CAAC,iBAAiB;AAAA,UACrB,OAAO;AAAA,UACP,OAAO,KAAK,SAAS,UAAU,MAAM,WAAW,EAAE,QAAQ,MAAM,GAAG;AAAA,QACrE,EAAE;AAAA,MACN;AAEA,UAAI,CAAC,cAAc,QAAQ;AACzB,wBAAgB;AAAA,UACd;AAAA,YACE,OAAO,UAAU;AAAA,YACjB,OAAO,UAAU;AAAA,UACnB;AAAA,QACF;AAAA,MACF;AAAA,IACF,OAAO;AACL,sBAAgB;AAAA,QACd;AAAA,UACE,OAAO,UAAU;AAAA,UACjB,OAAO,UAAU;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SACE,qBAAC,OAAI,eAAc,UACjB;AAAA,wBAAC,QAAK,OAAO,OAAO,MACjB,kDAAwC,MAAM,OAAO,IAAI,EAAE,UAAU,IAAI,CAAC,KAC7E;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,UACJ,aAAa;AAAA,YACX,SAAS;AAAA,UACX;AAAA,QACF;AAAA,QACA,
|
|
4
|
+
"sourcesContent": ["import {colors, type CommandArguments, Header, icons, 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 Workspace} from '../../workspace.js';\nimport {type CommandStatus, packageNameToDirectory} from '../internals.js';\nimport {type createProjectCommand} from './createProjectCommand.js';\nimport {CreateProjectInput, type CreateProjectInputResult} from './CreateProjectInput.js';\nimport {runCreateProject} from './runCreateProject.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<null | ZenObservable.Subscription>(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\n if (!possiblePaths.length) {\n possiblePaths = workspace.projectGlobs\n .filter((projectGlob) => !ONLY_ONE_STAR_REGEXP.test(projectGlob))\n .map((projectGlob) => path.join(workspace.path, projectGlob))\n .map((projectPath) => ({\n value: projectPath,\n label: path.relative(workspace.path, projectPath).replace('\\\\', '/'),\n }));\n }\n\n if (!possiblePaths.length) {\n possiblePaths = [\n {\n value: workspace.path,\n label: workspace.path,\n },\n ];\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 marginTop={1}\n values={createProjectInputResult}\n onChange={setCreateProjectInputResult}\n onComplete={setCreateProjectInputResult}\n />\n\n {status === 'in-progress' || status === 'finished' ?\n <Box flexDirection=\"column\" marginTop={1}>\n <Header icon={icons.success} marginBottom={1} showSpinner={status === 'in-progress'}>\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 icon={icons.success} marginTop={1}>\n <Text>Done.</Text>\n </Header>\n : null}\n </Box>\n );\n}\n"],
|
|
5
|
+
"mappings": ";AAiHM,cAiBE,YAjBF;AAjHN,SAAQ,QAA+B,QAAQ,OAAO,kBAAiB;AACvE,OAAO,WAAW;AAClB,SAAQ,KAAK,YAAW;AACxB,OAAO,UAAU;AACjB,SAAQ,WAAW,gBAAe;AAGlC,SAA4B,8BAA6B;AAEzD,SAAQ,0BAAwD;AAChE,SAAQ,wBAAuB;AAE/B,MAAM,uBAAuB;AAOtB,gBAAS,cAAc,EAAC,MAAM,UAAS,GAAuB;AACnE,MAAI,CAAC,QAAQ,SAAS,IAAI,SAAwB,aAAa;AAC/D,MAAI,CAAC,cAAc,eAAe,IAAI,SAA4C,IAAI;AACtF,MAAI,CAAC,MAAM,OAAO,IAAI,SAAmB,CAAC,CAAC;AAC3C,MAAI,CAAC,0BAA0B,2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;AAAA,QACX,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,YAAY;AAAA;AAAA,IACd;AAAA,IAEC,WAAW,iBAAiB,WAAW,aACtC,qBAAC,OAAI,eAAc,UAAS,WAAW,GACrC;AAAA,0BAAC,UAAO,MAAM,MAAM,SAAS,cAAc,GAAG,aAAa,WAAW,eACpE,8BAAC,QAAK,iCAAmB,GAC3B;AAAA,MAEC,KAAK,IAAI,CAAC,QACT,oBAAC,QAAgB,aAAG,MAAM,IAAI,IAAI,GAAG,MAA1B,GAA6B,CACzC;AAAA,OACH,IACA;AAAA,IAED,WAAW,aACV,oBAAC,UAAO,MAAM,MAAM,SAAS,WAAW,GACtC,8BAAC,QAAK,mBAAK,GACb,IACA;AAAA,KACJ;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../source/commands/create-project/runCreateProject.ts"],
|
|
4
|
-
"sourcesContent": ["import {type CommandArguments} from '@jakubmazanec/cli';\nimport Observable from 'zen-observable';\n\nimport {type Workspace} from '../../workspace.js';\nimport {type createProjectCommand} from './createProjectCommand.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 // if the project doesn't have config with a template ID, it's on purpose, but it's still needed for the next update, so we'll add it manually\n project.config.template ??= templateId;\n\n await project.update({args});\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error) => {\n observer.error(error);\n });\n });\n}\n"],
|
|
5
|
-
"mappings": ";AACA,OAAO,gBAAgB;AAehB,gBAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,SAAO,IAAI,WAAgC,CAAC,aAAa;AACvD,KAAC,YAAY;AACX,eAAS,KAAK,gBAAgB;AAE9B,UAAI,UAAU,MAAM,UAAU,cAAc;AAAA,QAC1C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAED,eAAS,KAAK,0BAA0B;AAGxC,cAAQ,OAAO,aAAa;AAE5B,YAAM,QAAQ,OAAO,EAAC,KAAI,CAAC;AAAA,IAC7B,GAAG,EACA,KAAK,MAAM;AACV,eAAS,SAAS;AAAA,IACpB,CAAC,EACA,MAAM,CAAC,
|
|
4
|
+
"sourcesContent": ["import {type CommandArguments} from '@jakubmazanec/cli';\nimport Observable from 'zen-observable';\n\nimport {type Workspace} from '../../workspace.js';\nimport {type createProjectCommand} from './createProjectCommand.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 // if the project doesn't have config with a template ID, it's on purpose, but it's still needed for the next update, so we'll add it manually\n project.config.template ??= templateId;\n\n await project.update({args});\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error: unknown) => {\n observer.error(error);\n });\n });\n}\n"],
|
|
5
|
+
"mappings": ";AACA,OAAO,gBAAgB;AAehB,gBAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,SAAO,IAAI,WAAgC,CAAC,aAAa;AACvD,KAAC,YAAY;AACX,eAAS,KAAK,gBAAgB;AAE9B,UAAI,UAAU,MAAM,UAAU,cAAc;AAAA,QAC1C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAED,eAAS,KAAK,0BAA0B;AAGxC,cAAQ,OAAO,aAAa;AAE5B,YAAM,QAAQ,OAAO,EAAC,KAAI,CAAC;AAAA,IAC7B,GAAG,EACA,KAAK,MAAM;AACV,eAAS,SAAS;AAAA,IACpB,CAAC,EACA,MAAM,CAAC,UAAmB;AACzB,eAAS,MAAM,KAAK;AAAA,IACtB,CAAC;AAAA,EACL,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -52,17 +52,17 @@ export function CreateWorkspace({ args }) {
|
|
|
52
52
|
/* @__PURE__ */ jsx(
|
|
53
53
|
CreateWorkspaceInput,
|
|
54
54
|
{
|
|
55
|
-
values: createWorkspaceInputResult,
|
|
56
55
|
marginTop: 1,
|
|
56
|
+
values: createWorkspaceInputResult,
|
|
57
57
|
onChange: setCreateWorkspaceInputResult,
|
|
58
58
|
onComplete: setCreateWorkspaceInputResult
|
|
59
59
|
}
|
|
60
60
|
),
|
|
61
|
-
status === "in-progress" || status === "finished" ? /* @__PURE__ */ jsxs(Box, {
|
|
62
|
-
/* @__PURE__ */ jsx(Header, { showSpinner: status === "in-progress",
|
|
61
|
+
status === "in-progress" || status === "finished" ? /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
62
|
+
/* @__PURE__ */ jsx(Header, { icon: icons.success, marginBottom: 1, showSpinner: status === "in-progress", children: /* @__PURE__ */ jsx(Text, { children: "Creating workspace..." }) }),
|
|
63
63
|
jobs.map((job) => /* @__PURE__ */ jsx(Text, { children: `${icons.info} ${job}` }, job))
|
|
64
64
|
] }) : null,
|
|
65
|
-
status === "finished" ? /* @__PURE__ */ jsx(Header, {
|
|
65
|
+
status === "finished" ? /* @__PURE__ */ jsx(Header, { icon: icons.success, marginTop: 1, children: /* @__PURE__ */ jsx(Text, { children: "Done." }) }) : null
|
|
66
66
|
] });
|
|
67
67
|
}
|
|
68
68
|
//# sourceMappingURL=CreateWorkspace.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../source/commands/create-workspace/CreateWorkspace.tsx"],
|
|
4
|
-
"sourcesContent": ["import {colors, type CommandArguments, Header, icons, 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 CommandStatus} from '../internals.js';\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};\n\nexport function CreateWorkspace({args}: CreateWorkspaceProps) {\n let [status, setStatus] = useState<CommandStatus>('not-started');\n let [subscription, setSubscription] = useState<ZenObservable.Subscription
|
|
5
|
-
"mappings": ";AA+DM,cAUE,YAVF;AA/DN,SAAQ,QAA+B,QAAQ,OAAO,kBAAiB;AACvE,OAAO,WAAW;AAClB,SAAQ,KAAK,YAAW;AACxB,OAAO,UAAU;AACjB,SAAQ,WAAW,gBAAe;AAIlC,SAAQ,4BAA4D;AACpE,SAAQ,0BAAyB;AAM1B,gBAAS,gBAAgB,EAAC,KAAI,GAAyB;AAC5D,MAAI,CAAC,QAAQ,SAAS,IAAI,SAAwB,aAAa;AAC/D,MAAI,CAAC,cAAc,eAAe,IAAI,SAA4C,IAAI;AACtF,MAAI,CAAC,MAAM,OAAO,IAAI,SAAmB,CAAC,CAAC;AAC3C,MAAI,CAAC,4BAA4B,6BAA6B,IAC5D,SAAqC,OAAO;AAAA,IAC1C,YAAY,EAAC,OAAO,KAAK,QAAQ,YAAY,IAAI,YAAY,CAAC,CAAC,KAAK,QAAQ,SAAQ;AAAA,EACtF,EAAE;AACJ,MAAI,EAAC,KAAI,IAAI,WAAW;AACxB,MAAI,gBAAgB,KAAK,QAAQ,QAAQ,IAAI,GAAG,KAAK,QAAQ,QAAQ,EAAE;AAEvE,YAAU,MAAM;AACd,QAAI,OAAO,QAAQ,0BAA0B,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,MAAM,OAAO,UAAU,GAAG;AACvF,gBAAU,aAAa;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,0BAA0B,CAAC;AAE/B,YAAU,MAAM;AACd,QAAI,WAAW,iBAAiB,CAAC,cAAc;AAC7C,UAAI,kBAAkB,mBAAmB;AAAA,QACvC;AAAA,QACA,YAAY,2BAA2B,WAAW;AAAA,QAClD;AAAA,MACF,CAAC,EAAE,UAAU;AAAA,QACX,KAAK,OAAO;AACV,kBAAQ,CAAC,iBAAiB,CAAC,GAAG,cAAc,KAAK,CAAC;AAAA,QACpD;AAAA,QACA,MAAM,OAAO;AACX,eAAK,KAAK;AAAA,QACZ;AAAA,QACA,WAAW;AACT,0BAAgB,YAAY;AAC5B,oBAAU,UAAU;AAAA,QACtB;AAAA,MACF,CAAC;AAED,sBAAgB,eAAe;AAAA,IACjC;AAEA,WAAO,MAAM;AACX,UAAI,cAAc;AAChB,qBAAa,YAAY;AAAA,MAC3B;AAAA,IACF;AAAA,EACF,GAAG,CAAC,4BAA4B,QAAQ,cAAc,MAAM,MAAM,aAAa,CAAC;AAEhF,SACE,qBAAC,OAAI,eAAc,UACjB;AAAA,wBAAC,QAAM,mCAAyB,MAAM,OAAO,IAAI,EAAE,aAAa,CAAC,KAAI;AAAA,IAErE;AAAA,MAAC;AAAA;AAAA,QACC,
|
|
4
|
+
"sourcesContent": ["import {colors, type CommandArguments, Header, icons, 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 CommandStatus} from '../internals.js';\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};\n\nexport function CreateWorkspace({args}: CreateWorkspaceProps) {\n let [status, setStatus] = useState<CommandStatus>('not-started');\n let [subscription, setSubscription] = useState<null | ZenObservable.Subscription>(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.info](workspacePath)}.`}</Text>\n\n <CreateWorkspaceInput\n marginTop={1}\n values={createWorkspaceInputResult}\n onChange={setCreateWorkspaceInputResult}\n onComplete={setCreateWorkspaceInputResult}\n />\n\n {status === 'in-progress' || status === 'finished' ?\n <Box flexDirection=\"column\" marginTop={1}>\n <Header icon={icons.success} marginBottom={1} showSpinner={status === 'in-progress'}>\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 icon={icons.success} marginTop={1}>\n <Text>Done.</Text>\n </Header>\n : null}\n </Box>\n );\n}\n"],
|
|
5
|
+
"mappings": ";AA+DM,cAUE,YAVF;AA/DN,SAAQ,QAA+B,QAAQ,OAAO,kBAAiB;AACvE,OAAO,WAAW;AAClB,SAAQ,KAAK,YAAW;AACxB,OAAO,UAAU;AACjB,SAAQ,WAAW,gBAAe;AAIlC,SAAQ,4BAA4D;AACpE,SAAQ,0BAAyB;AAM1B,gBAAS,gBAAgB,EAAC,KAAI,GAAyB;AAC5D,MAAI,CAAC,QAAQ,SAAS,IAAI,SAAwB,aAAa;AAC/D,MAAI,CAAC,cAAc,eAAe,IAAI,SAA4C,IAAI;AACtF,MAAI,CAAC,MAAM,OAAO,IAAI,SAAmB,CAAC,CAAC;AAC3C,MAAI,CAAC,4BAA4B,6BAA6B,IAC5D,SAAqC,OAAO;AAAA,IAC1C,YAAY,EAAC,OAAO,KAAK,QAAQ,YAAY,IAAI,YAAY,CAAC,CAAC,KAAK,QAAQ,SAAQ;AAAA,EACtF,EAAE;AACJ,MAAI,EAAC,KAAI,IAAI,WAAW;AACxB,MAAI,gBAAgB,KAAK,QAAQ,QAAQ,IAAI,GAAG,KAAK,QAAQ,QAAQ,EAAE;AAEvE,YAAU,MAAM;AACd,QAAI,OAAO,QAAQ,0BAA0B,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,MAAM,OAAO,UAAU,GAAG;AACvF,gBAAU,aAAa;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,0BAA0B,CAAC;AAE/B,YAAU,MAAM;AACd,QAAI,WAAW,iBAAiB,CAAC,cAAc;AAC7C,UAAI,kBAAkB,mBAAmB;AAAA,QACvC;AAAA,QACA,YAAY,2BAA2B,WAAW;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
-
"sourcesContent": ["import {type CommandArguments} from '@jakubmazanec/cli';\nimport Observable from 'zen-observable';\n\nimport {Workspace} from '../../workspace.js';\nimport {type createWorkspaceCommand} from './createWorkspaceCommand.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 // if the workspace doesn't have config with a template ID, it's on purpose, but it's still needed for the next update, so we'll add it manually\n workspace.config.template ??= templateId;\n\n await workspace.update({args});\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error) => {\n observer.error(error);\n });\n });\n}\n"],
|
|
5
|
-
"mappings": ";AACA,OAAO,gBAAgB;AAEvB,SAAQ,iBAAgB;AAWjB,gBAAS,mBAAmB,EAAC,eAAe,YAAY,KAAI,GAA2B;AAC5F,SAAO,IAAI,WAAkC,CAAC,aAAa;AACzD,KAAC,YAAY;AACX,eAAS,KAAK,gBAAgB;AAE9B,UAAI,YAAY,MAAM,UAAU,OAAO;AAAA,QACrC;AAAA,QACA,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAED,eAAS,KAAK,4BAA4B;AAG1C,gBAAU,OAAO,aAAa;AAE9B,YAAM,UAAU,OAAO,EAAC,KAAI,CAAC;AAAA,IAC/B,GAAG,EACA,KAAK,MAAM;AACV,eAAS,SAAS;AAAA,IACpB,CAAC,EACA,MAAM,CAAC,
|
|
4
|
+
"sourcesContent": ["import {type CommandArguments} from '@jakubmazanec/cli';\nimport Observable from 'zen-observable';\n\nimport {Workspace} from '../../workspace.js';\nimport {type createWorkspaceCommand} from './createWorkspaceCommand.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 // if the workspace doesn't have config with a template ID, it's on purpose, but it's still needed for the next update, so we'll add it manually\n workspace.config.template ??= templateId;\n\n await workspace.update({args});\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error: unknown) => {\n observer.error(error);\n });\n });\n}\n"],
|
|
5
|
+
"mappings": ";AACA,OAAO,gBAAgB;AAEvB,SAAQ,iBAAgB;AAWjB,gBAAS,mBAAmB,EAAC,eAAe,YAAY,KAAI,GAA2B;AAC5F,SAAO,IAAI,WAAkC,CAAC,aAAa;AACzD,KAAC,YAAY;AACX,eAAS,KAAK,gBAAgB;AAE9B,UAAI,YAAY,MAAM,UAAU,OAAO;AAAA,QACrC;AAAA,QACA,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAED,eAAS,KAAK,4BAA4B;AAG1C,gBAAU,OAAO,aAAa;AAE9B,YAAM,UAAU,OAAO,EAAC,KAAI,CAAC;AAAA,IAC/B,GAAG,EACA,KAAK,MAAM;AACV,eAAS,SAAS;AAAA,IACpB,CAAC,EACA,MAAM,CAAC,UAAmB;AACzB,eAAS,MAAM,KAAK;AAAA,IACtB,CAAC;AAAA,EACL,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,11 +27,11 @@ export function UpdateWorkspace({ workspace, args }) {
|
|
|
27
27
|
}, [args, exit, workspace]);
|
|
28
28
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
29
29
|
/* @__PURE__ */ jsx(Text, { children: `Updating workspace at ${chalk[colors.info](workspace.path)}.` }),
|
|
30
|
-
/* @__PURE__ */ jsxs(Box, {
|
|
31
|
-
/* @__PURE__ */ jsx(Header, {
|
|
30
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
31
|
+
/* @__PURE__ */ jsx(Header, { icon: icons.success, marginBottom: 1, showSpinner: !isFinished, children: /* @__PURE__ */ jsx(Text, { children: "Updating workspace and projects..." }) }),
|
|
32
32
|
jobs.map((job) => /* @__PURE__ */ jsx(Text, { children: `${icons.info} ${job}` }, job))
|
|
33
33
|
] }),
|
|
34
|
-
isFinished ? /* @__PURE__ */ jsx(Header, {
|
|
34
|
+
isFinished ? /* @__PURE__ */ jsx(Header, { icon: icons.success, marginTop: 1, children: /* @__PURE__ */ jsx(Text, { children: "Done." }) }) : null
|
|
35
35
|
] });
|
|
36
36
|
}
|
|
37
37
|
//# sourceMappingURL=UpdateWorkspace.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../source/commands/update-workspace/UpdateWorkspace.tsx"],
|
|
4
|
-
"sourcesContent": ["import {colors, type CommandArguments, Header, icons, useProgram} from '@jakubmazanec/cli';\nimport chalk from 'chalk';\nimport {Box, Text} from 'ink';\nimport {useEffect, useState} from 'react';\n\nimport {type Workspace} from '../../workspace.js';\nimport {runUpdateWorkspace} from './runUpdateWorkspace.js';\nimport {type updateWorkspaceCommand} from './updateWorkspaceCommand.js';\n\nexport type UpdateWorkspaceProps = {\n args: CommandArguments<typeof updateWorkspaceCommand>;\n workspace: Workspace | Workspace<false>;\n};\n\nexport function UpdateWorkspace({workspace, args}: UpdateWorkspaceProps) {\n let [isFinished, setIsFinished] = useState(false);\n let [jobs, setJobs] = useState<string[]>([]);\n let {exit} = useProgram();\n\n useEffect(() => {\n let subscription = runUpdateWorkspace({workspace, args}).subscribe({\n next(value) {\n setJobs((previousJobs) => [...previousJobs, value]);\n },\n error(error) {\n exit(error);\n },\n complete() {\n setIsFinished(true);\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [args, exit, workspace]);\n\n return (\n <Box flexDirection=\"column\">\n <Text>{`Updating workspace at ${chalk[colors.info](workspace.path)}.`}</Text>\n\n <Box
|
|
5
|
-
"mappings": ";AAuCM,cAEA,YAFA;AAvCN,SAAQ,QAA+B,QAAQ,OAAO,kBAAiB;AACvE,OAAO,WAAW;AAClB,SAAQ,KAAK,YAAW;AACxB,SAAQ,WAAW,gBAAe;AAGlC,SAAQ,0BAAyB;AAQ1B,gBAAS,gBAAgB,EAAC,WAAW,KAAI,GAAyB;AACvE,MAAI,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAChD,MAAI,CAAC,MAAM,OAAO,IAAI,SAAmB,CAAC,CAAC;AAC3C,MAAI,EAAC,KAAI,IAAI,WAAW;AAExB,YAAU,MAAM;AACd,QAAI,eAAe,mBAAmB,EAAC,WAAW,KAAI,CAAC,EAAE,UAAU;AAAA,MACjE,KAAK,OAAO;AACV,gBAAQ,CAAC,iBAAiB,CAAC,GAAG,cAAc,KAAK,CAAC;AAAA,MACpD;AAAA,MACA,MAAM,OAAO;AACX,aAAK,KAAK;AAAA,MACZ;AAAA,MACA,WAAW;AACT,sBAAc,IAAI;AAAA,MACpB;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,mBAAa,YAAY;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,MAAM,MAAM,SAAS,CAAC;AAE1B,SACE,qBAAC,OAAI,eAAc,UACjB;AAAA,wBAAC,QAAM,mCAAyB,MAAM,OAAO,IAAI,EAAE,UAAU,IAAI,CAAC,KAAI;AAAA,IAEtE,qBAAC,OAAI,
|
|
4
|
+
"sourcesContent": ["import {colors, type CommandArguments, Header, icons, useProgram} from '@jakubmazanec/cli';\nimport chalk from 'chalk';\nimport {Box, Text} from 'ink';\nimport {useEffect, useState} from 'react';\n\nimport {type Workspace} from '../../workspace.js';\nimport {runUpdateWorkspace} from './runUpdateWorkspace.js';\nimport {type updateWorkspaceCommand} from './updateWorkspaceCommand.js';\n\nexport type UpdateWorkspaceProps = {\n args: CommandArguments<typeof updateWorkspaceCommand>;\n workspace: Workspace | Workspace<false>;\n};\n\nexport function UpdateWorkspace({workspace, args}: UpdateWorkspaceProps) {\n let [isFinished, setIsFinished] = useState(false);\n let [jobs, setJobs] = useState<string[]>([]);\n let {exit} = useProgram();\n\n useEffect(() => {\n let subscription = runUpdateWorkspace({workspace, args}).subscribe({\n next(value) {\n setJobs((previousJobs) => [...previousJobs, value]);\n },\n error(error) {\n exit(error);\n },\n complete() {\n setIsFinished(true);\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [args, exit, workspace]);\n\n return (\n <Box flexDirection=\"column\">\n <Text>{`Updating workspace at ${chalk[colors.info](workspace.path)}.`}</Text>\n\n <Box flexDirection=\"column\" marginTop={1}>\n <Header icon={icons.success} marginBottom={1} showSpinner={!isFinished}>\n <Text>Updating workspace and projects...</Text>\n </Header>\n\n {jobs.map((job) => (\n <Text key={job}>{`${icons.info} ${job}`}</Text>\n ))}\n </Box>\n\n {isFinished ?\n <Header icon={icons.success} marginTop={1}>\n <Text>Done.</Text>\n </Header>\n : null}\n </Box>\n );\n}\n"],
|
|
5
|
+
"mappings": ";AAuCM,cAEA,YAFA;AAvCN,SAAQ,QAA+B,QAAQ,OAAO,kBAAiB;AACvE,OAAO,WAAW;AAClB,SAAQ,KAAK,YAAW;AACxB,SAAQ,WAAW,gBAAe;AAGlC,SAAQ,0BAAyB;AAQ1B,gBAAS,gBAAgB,EAAC,WAAW,KAAI,GAAyB;AACvE,MAAI,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAChD,MAAI,CAAC,MAAM,OAAO,IAAI,SAAmB,CAAC,CAAC;AAC3C,MAAI,EAAC,KAAI,IAAI,WAAW;AAExB,YAAU,MAAM;AACd,QAAI,eAAe,mBAAmB,EAAC,WAAW,KAAI,CAAC,EAAE,UAAU;AAAA,MACjE,KAAK,OAAO;AACV,gBAAQ,CAAC,iBAAiB,CAAC,GAAG,cAAc,KAAK,CAAC;AAAA,MACpD;AAAA,MACA,MAAM,OAAO;AACX,aAAK,KAAK;AAAA,MACZ;AAAA,MACA,WAAW;AACT,sBAAc,IAAI;AAAA,MACpB;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,mBAAa,YAAY;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,MAAM,MAAM,SAAS,CAAC;AAE1B,SACE,qBAAC,OAAI,eAAc,UACjB;AAAA,wBAAC,QAAM,mCAAyB,MAAM,OAAO,IAAI,EAAE,UAAU,IAAI,CAAC,KAAI;AAAA,IAEtE,qBAAC,OAAI,eAAc,UAAS,WAAW,GACrC;AAAA,0BAAC,UAAO,MAAM,MAAM,SAAS,cAAc,GAAG,aAAa,CAAC,YAC1D,8BAAC,QAAK,gDAAkC,GAC1C;AAAA,MAEC,KAAK,IAAI,CAAC,QACT,oBAAC,QAAgB,aAAG,MAAM,IAAI,IAAI,GAAG,MAA1B,GAA6B,CACzC;AAAA,OACH;AAAA,IAEC,aACC,oBAAC,UAAO,MAAM,MAAM,SAAS,WAAW,GACtC,8BAAC,QAAK,mBAAK,GACb,IACA;AAAA,KACJ;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../source/commands/update-workspace/runUpdateWorkspace.ts"],
|
|
4
|
-
"sourcesContent": ["import {type CommandArguments} from '@jakubmazanec/cli';\nimport Observable from 'zen-observable';\n\nimport {type Workspace} from '../../workspace.js';\nimport {type updateWorkspaceCommand} from './updateWorkspaceCommand.js';\n\nexport type UpdateWorkspaceAndProjectsOptions = {\n workspace: Workspace | Workspace<false>;\n args: CommandArguments<typeof updateWorkspaceCommand>;\n};\n\nexport type UpdateWorkspaceAndProjectsStatus = string;\n\nexport function runUpdateWorkspace({workspace, args}: UpdateWorkspaceAndProjectsOptions) {\n return new Observable<UpdateWorkspaceAndProjectsStatus>((observer) => {\n (async () => {\n // update workspace\n observer.next('Updating workspace');\n\n await workspace.update({args});\n\n // update projects\n for (let project of workspace.projects) {\n observer.next(`Updating project ${project.name ?? '?'}`);\n\n await project.update({args});\n }\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error) => {\n observer.error(error);\n });\n });\n}\n"],
|
|
5
|
-
"mappings": ";AACA,OAAO,gBAAgB;AAYhB,gBAAS,mBAAmB,EAAC,WAAW,KAAI,GAAsC;AACvF,SAAO,IAAI,WAA6C,CAAC,aAAa;AACpE,KAAC,YAAY;AAEX,eAAS,KAAK,oBAAoB;AAElC,YAAM,UAAU,OAAO,EAAC,KAAI,CAAC;AAG7B,eAAS,WAAW,UAAU,UAAU;AACtC,iBAAS,KAAK,oBAAoB,QAAQ,QAAQ,GAAG,EAAE;AAEvD,cAAM,QAAQ,OAAO,EAAC,KAAI,CAAC;AAAA,MAC7B;AAAA,IACF,GAAG,EACA,KAAK,MAAM;AACV,eAAS,SAAS;AAAA,IACpB,CAAC,EACA,MAAM,CAAC,
|
|
4
|
+
"sourcesContent": ["import {type CommandArguments} from '@jakubmazanec/cli';\nimport Observable from 'zen-observable';\n\nimport {type Workspace} from '../../workspace.js';\nimport {type updateWorkspaceCommand} from './updateWorkspaceCommand.js';\n\nexport type UpdateWorkspaceAndProjectsOptions = {\n workspace: Workspace | Workspace<false>;\n args: CommandArguments<typeof updateWorkspaceCommand>;\n};\n\nexport type UpdateWorkspaceAndProjectsStatus = string;\n\nexport function runUpdateWorkspace({workspace, args}: UpdateWorkspaceAndProjectsOptions) {\n return new Observable<UpdateWorkspaceAndProjectsStatus>((observer) => {\n (async () => {\n // update workspace\n observer.next('Updating workspace');\n\n await workspace.update({args});\n\n // update projects\n for (let project of workspace.projects) {\n observer.next(`Updating project ${project.name ?? '?'}`);\n\n await project.update({args});\n }\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error: unknown) => {\n observer.error(error);\n });\n });\n}\n"],
|
|
5
|
+
"mappings": ";AACA,OAAO,gBAAgB;AAYhB,gBAAS,mBAAmB,EAAC,WAAW,KAAI,GAAsC;AACvF,SAAO,IAAI,WAA6C,CAAC,aAAa;AACpE,KAAC,YAAY;AAEX,eAAS,KAAK,oBAAoB;AAElC,YAAM,UAAU,OAAO,EAAC,KAAI,CAAC;AAG7B,eAAS,WAAW,UAAU,UAAU;AACtC,iBAAS,KAAK,oBAAoB,QAAQ,QAAQ,GAAG,EAAE;AAEvD,cAAM,QAAQ,OAAO,EAAC,KAAI,CAAC;AAAA,MAC7B;AAAA,IACF,GAAG,EACA,KAAK,MAAM;AACV,eAAS,SAAS;AAAA,IACpB,CAAC,EACA,MAAM,CAAC,UAAmB;AACzB,eAAS,MAAM,KAAK;AAAA,IACtB,CAAC;AAAA,EACL,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ export const updateWorkspaceCommand = new Command(
|
|
|
17
17
|
throw project.errors[0];
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
await program.renderElement(/* @__PURE__ */ jsx(UpdateWorkspace, {
|
|
20
|
+
await program.renderElement(/* @__PURE__ */ jsx(UpdateWorkspace, { args, workspace }));
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
description: "Updates files in a workspace.",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../source/commands/update-workspace/updateWorkspaceCommand.tsx"],
|
|
4
|
-
"sourcesContent": ["import {Command} from '@jakubmazanec/cli';\nimport path from 'node:path';\n\nimport {Workspace} from '../../workspace.js';\nimport {UpdateWorkspace} from './UpdateWorkspace.js';\n\nexport const updateWorkspaceCommand = new Command(\n 'update workspace',\n async (args, program) => {\n let resolvedPath = path.resolve(process.cwd(), args.options.path ?? '');\n let workspace = await Workspace.findAndRead(resolvedPath, {throwIfNotFound: true});\n\n if (workspace.errors[0]) {\n throw workspace.errors[0];\n }\n\n for (let project of workspace.projects) {\n if (project.errors[0]) {\n throw project.errors[0];\n }\n }\n\n await program.renderElement(<UpdateWorkspace
|
|
5
|
-
"mappings": ";AAsBgC;AAtBhC,SAAQ,eAAc;AACtB,OAAO,UAAU;AAEjB,SAAQ,iBAAgB;AACxB,SAAQ,uBAAsB;AAEvB,aAAM,yBAAyB,IAAI;AAAA,EACxC;AAAA,EACA,OAAO,MAAM,YAAY;AACvB,QAAI,eAAe,KAAK,QAAQ,QAAQ,IAAI,GAAG,KAAK,QAAQ,QAAQ,EAAE;AACtE,QAAI,YAAY,MAAM,UAAU,YAAY,cAAc,EAAC,iBAAiB,KAAI,CAAC;AAEjF,QAAI,UAAU,OAAO,CAAC,GAAG;AACvB,YAAM,UAAU,OAAO,CAAC;AAAA,IAC1B;AAEA,aAAS,WAAW,UAAU,UAAU;AACtC,UAAI,QAAQ,OAAO,CAAC,GAAG;AACrB,cAAM,QAAQ,OAAO,CAAC;AAAA,MACxB;AAAA,IACF;AAEA,UAAM,QAAQ,cAAc,oBAAC,mBAAgB,WAAsB,
|
|
4
|
+
"sourcesContent": ["import {Command} from '@jakubmazanec/cli';\nimport path from 'node:path';\n\nimport {Workspace} from '../../workspace.js';\nimport {UpdateWorkspace} from './UpdateWorkspace.js';\n\nexport const updateWorkspaceCommand = new Command(\n 'update workspace',\n async (args, program) => {\n let resolvedPath = path.resolve(process.cwd(), args.options.path ?? '');\n let workspace = await Workspace.findAndRead(resolvedPath, {throwIfNotFound: true});\n\n if (workspace.errors[0]) {\n throw workspace.errors[0];\n }\n\n for (let project of workspace.projects) {\n if (project.errors[0]) {\n throw project.errors[0];\n }\n }\n\n await program.renderElement(<UpdateWorkspace args={args} workspace={workspace} />);\n },\n {\n description: 'Updates files in a workspace.',\n options: {\n path: {\n type: 'string',\n },\n },\n },\n);\n"],
|
|
5
|
+
"mappings": ";AAsBgC;AAtBhC,SAAQ,eAAc;AACtB,OAAO,UAAU;AAEjB,SAAQ,iBAAgB;AACxB,SAAQ,uBAAsB;AAEvB,aAAM,yBAAyB,IAAI;AAAA,EACxC;AAAA,EACA,OAAO,MAAM,YAAY;AACvB,QAAI,eAAe,KAAK,QAAQ,QAAQ,IAAI,GAAG,KAAK,QAAQ,QAAQ,EAAE;AACtE,QAAI,YAAY,MAAM,UAAU,YAAY,cAAc,EAAC,iBAAiB,KAAI,CAAC;AAEjF,QAAI,UAAU,OAAO,CAAC,GAAG;AACvB,YAAM,UAAU,OAAO,CAAC;AAAA,IAC1B;AAEA,aAAS,WAAW,UAAU,UAAU;AACtC,UAAI,QAAQ,OAAO,CAAC,GAAG;AACrB,cAAM,QAAQ,OAAO,CAAC;AAAA,MACxB;AAAA,IACF;AAEA,UAAM,QAAQ,cAAc,oBAAC,mBAAgB,MAAY,WAAsB,CAAE;AAAA,EACnF;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,SAAS;AAAA,MACP,MAAM;AAAA,QACJ,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,8 +4,8 @@ import { type templateDataSchema } from './TemplateData.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* A result of rendering a Carson template file.
|
|
6
6
|
*/
|
|
7
|
-
export type TemplateRender =
|
|
7
|
+
export type TemplateRender = {
|
|
8
8
|
template: {
|
|
9
9
|
path: string;
|
|
10
10
|
};
|
|
11
|
-
}
|
|
11
|
+
} & BaseTemplateRender<typeof templateAttributesSchema, typeof templateDataSchema>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/template/applyTemplateRenders.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import fs from 'fs-extra';\nimport path from 'node:path';\nimport prettier from 'prettier';\n\nimport {CARSON_CONFIG_DIRECTORY} from '../constants.js';\nimport {CarsonTemplateError} from './CarsonTemplateError.js';\nimport {\n createUsingTemplateRender,\n deleteUsingTemplateRender,\n insertUsingTemplateRender,\n loadTemplateRenderSnapshots,\n mergeUsingTemplateRender,\n overwriteUsingTemplateRender,\n saveTemplateRenderSnapshots,\n uninsertUsingTemplateRender,\n unmergeUsingTemplateRender,\n} from './internals.js';\nimport {type TemplateRenders} from './TemplateRenders.js';\n\nexport type ApplyTemplateRendersOptions = {\n templateRenders: TemplateRenders;\n targetPath: string;\n snapshotPath?: string | undefined;\n ignoreStrategies: string[];\n};\n\n/**\n * Applies rendered Carson template to a specified path, i.e. creates and updates files based on the result of rendering each Carson template file.\n */\nexport async function applyTemplateRenders({\n templateRenders,\n targetPath,\n snapshotPath,\n ignoreStrategies,\n}: ApplyTemplateRendersOptions) {\n // we need to clear Prettier cache, because we are changing file system\n await prettier.clearConfigCache();\n\n // first, we read the existing snapshots and use them to undo previous changes\n if (snapshotPath && (await fs.pathExists(snapshotPath))) {\n let templateRenderSnapshots = await loadTemplateRenderSnapshots(snapshotPath);\n\n for (let templateRenderSnapshot of templateRenderSnapshots) {\n let strategy =\n typeof templateRenderSnapshot.attributes.strategy === 'string' ?\n templateRenderSnapshot.attributes.strategy\n : templateRenderSnapshot.attributes.strategy[0];\n\n if (ignoreStrategies.includes(strategy)) {\n continue;\n }\n\n if (templateRenderSnapshot.attributes.strategy === 'ensure') {\n await deleteUsingTemplateRender(templateRenderSnapshot, targetPath, {\n onlyDeleteWhenContentsMatch: true,\n });\n }\n\n if (templateRenderSnapshot.attributes.strategy === 'overwrite') {\n await deleteUsingTemplateRender(templateRenderSnapshot, targetPath);\n }\n\n if (templateRenderSnapshot.attributes.strategy === 'merge') {\n await unmergeUsingTemplateRender(templateRenderSnapshot, targetPath);\n }\n\n if (templateRenderSnapshot.attributes.strategy[0] === 'insert') {\n await uninsertUsingTemplateRender(templateRenderSnapshot, targetPath);\n }\n }\n }\n\n // second, we apply strategies that create files\n for (let templateRender of templateRenders) {\n let strategy =\n typeof templateRender.attributes.strategy === 'string' ?\n templateRender.attributes.strategy\n : templateRender.attributes.strategy[0];\n\n if (ignoreStrategies.includes(strategy)) {\n continue;\n }\n\n if (templateRender.attributes.strategy === 'create') {\n await createUsingTemplateRender(templateRender, targetPath);\n }\n\n if (templateRender.attributes.strategy === 'ensure') {\n let to = path.join(targetPath, templateRender.attributes.to);\n let doesToExist = await fs.pathExists(to);\n\n if (!doesToExist) {\n await createUsingTemplateRender(templateRender, targetPath);\n }\n }\n }\n\n // third, we apply strategies that change files\n for (let templateRender of templateRenders) {\n let strategy =\n typeof templateRender.attributes.strategy === 'string' ?\n templateRender.attributes.strategy\n : templateRender.attributes.strategy[0];\n\n if (ignoreStrategies.includes(strategy)) {\n continue;\n }\n\n if (templateRender.attributes.strategy === 'overwrite') {\n await overwriteUsingTemplateRender(templateRender, targetPath);\n }\n\n if (templateRender.attributes.strategy === 'merge') {\n await mergeUsingTemplateRender(templateRender, targetPath);\n }\n\n if (templateRender.attributes.strategy[0] === 'insert') {\n await insertUsingTemplateRender(templateRender, targetPath);\n }\n\n if (templateRender.attributes.strategy === 'check') {\n let to = path.join(targetPath, templateRender.attributes.to);\n let doesToExist = await fs.pathExists(to);\n\n if (!doesToExist) {\n throw new CarsonTemplateError('STRATEGY_MISSING_FILE', {\n messageParameters: [templateRender.attributes.strategy, templateRender.template.path, to],\n data: {\n path: to,\n },\n });\n }\n }\n }\n\n if (snapshotPath) {\n await fs.ensureDir(path.join(targetPath, CARSON_CONFIG_DIRECTORY));\n\n await saveTemplateRenderSnapshots(templateRenders, snapshotPath);\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,cAAc;AAErB,SAAQ,+BAA8B;AACtC,SAAQ,2BAA0B;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAaP,sBAAsB,qBAAqB;AAAA,EACzC;AAAA,EACA;AAA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;AAAA,EACF;AAGA,WAAS,kBAAkB,iBAAiB;AAC1C,QAAI,WACF,OAAO,eAAe,WAAW,aAAa,WAC5C,eAAe,WAAW,WAC1B,eAAe,WAAW,SAAS,CAAC;AAExC,QAAI,iBAAiB,SAAS,QAAQ,GAAG;AACvC;AAAA,IACF;AAEA,QAAI,eAAe,WAAW,aAAa,aAAa;AACtD,YAAM,6BAA6B,gBAAgB,UAAU;AAAA,IAC/D;AAEA,QAAI,eAAe,WAAW,aAAa,SAAS;AAClD,YAAM,yBAAyB,gBAAgB,UAAU;AAAA,IAC3D;AAEA,QAAI,eAAe,WAAW,SAAS,CAAC,MAAM,UAAU;AACtD,YAAM,0BAA0B,gBAAgB,UAAU;AAAA,IAC5D;AAEA,QAAI,eAAe,WAAW,aAAa,SAAS;AAClD,UAAI,KAAK,KAAK,KAAK,YAAY,eAAe,WAAW,EAAE;AAC3D,UAAI,cAAc,MAAM,GAAG,WAAW,EAAE;AAExC,UAAI,CAAC,aAAa;AAChB,cAAM,IAAI,oBAAoB,yBAAyB;AAAA,UACrD,mBAAmB,CAAC,eAAe,WAAW,UAAU,eAAe,SAAS,MAAM,EAAE;AAAA,UACxF,MAAM;AAAA,YACJ,MAAM;AAAA,UACR;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,MAAI,cAAc;AAChB,UAAM,GAAG,UAAU,KAAK,KAAK,YAAY,uBAAuB,CAAC;AAEjE,UAAM,4BAA4B,iBAAiB,YAAY;AAAA,EACjE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -60,7 +60,7 @@ export declare class Workspace<M extends boolean = true> {
|
|
|
60
60
|
/**
|
|
61
61
|
* Traverses file system up from the search path and tries to find and read a workspace.
|
|
62
62
|
*/
|
|
63
|
-
static findAndRead<O extends
|
|
63
|
+
static findAndRead<O extends undefined | WorkspaceFindAndReadOptions = undefined>(searchPath: string, options?: O): Promise<O extends undefined ? undefined | Workspace | Workspace<false> : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false> : undefined | Workspace | Workspace<false>>;
|
|
64
64
|
read(): Promise<this>;
|
|
65
65
|
update({ args }: WorkspaceUpdateOptions): Promise<this>;
|
|
66
66
|
getProject(projectName: Project<M> | string): Project<M> | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/workspace/Workspace.ts"],
|
|
4
|
-
"sourcesContent": ["import {ensureEmptyDirectory, findExistingDirectory, isRootPath} from '@jakubmazanec/fs-utils';\nimport {jsonSchema, type PackageJson, packageJsonSchema, readFile} from '@jakubmazanec/zod-utils';\nimport glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport json5 from 'json5';\nimport _ from 'lodash';\nimport path from 'node:path';\nimport {z} from 'zod';\n\nimport {\n CARSON_CONFIG_DIRECTORY,\n PACKAGE_JSON_FILENAME,\n WORKSPACE_CONFIG_FILENAME,\n WORKSPACE_SNAPSHOT_FILENAME,\n} from '../constants.js';\nimport {applyTemplateRenders} from '../template/applyTemplateRenders.js';\nimport {readCarsonTemplate} from '../template/internals.js';\nimport {renderCarsonTemplate} from '../template/renderCarsonTemplate.js';\nimport {\n compareProjectPath,\n containsProject,\n containsWorkspace,\n getPackageJsonWorkspaces,\n getRepositoryBranches,\n getRepositoryUrl,\n} from './internals.js';\nimport {Project} from './Project.js';\nimport {saveWorkspaceConfig} from './saveWorkspaceConfig.js';\nimport {workspaceConfigSchema} from './WorkspaceConfig.js';\nimport {type WorkspaceConfig} from './WorkspaceConfig.js';\nimport {type WorkspaceCreateOptions} from './WorkspaceCreateOptions.js';\nimport {type WorkspaceCreateProjectOptions} from './WorkspaceCreateProjectOptions.js';\nimport {WorkspaceDependencies} from './WorkspaceDependencies.js';\nimport {WorkspaceError} from './WorkspaceError.js';\nimport {type WorkspaceFindAndReadOptions} from './WorkspaceFindAndReadOptions.js';\nimport {type WorkspaceOptions} from './WorkspaceOptions.js';\nimport {type WorkspacePackageJson} from './WorkspacePackageJson.js';\nimport {type WorkspaceProjectGlobs} from './WorkspaceProjectGlobs.js';\nimport {type WorkspaceProjects} from './WorkspaceProjects.js';\nimport {type WorkspaceRepository} from './WorkspaceRepository.js';\nimport {type WorkspaceUpdateOptions} from './WorkspaceUpdateOptions.js';\n\n/**\n * Workspace represent a directory, usually a git repository, that contains {@link Project} instances.\n *\n * @typeParam M If true, the workspace is multi-project workspace (so-called \"monorepo\").\n */\nexport class Workspace<M extends boolean = true> {\n /** Workspace path. */\n readonly path: string;\n\n /** Does the workspace contain a multiple projects? */\n readonly isMultiProject: M;\n\n /** Globs used to find projects. */\n projectGlobs: WorkspaceProjectGlobs<M>;\n\n /** Workspace projects. */\n projects: WorkspaceProjects<M>;\n\n /** Workspace configuration; if it's not found, the default is an empty object. */\n config: WorkspaceConfig;\n\n /** Parsed workspace `package.json` file (if the workspace contains multiple projects); if it's not found, the default is an empty object. */\n packageJson: WorkspacePackageJson<M>;\n\n /** Workspace git repository. */\n repository?: WorkspaceRepository;\n\n /** Dependencies of all projects. */\n dependencies: WorkspaceDependencies<M> = [] as unknown as WorkspaceDependencies<M>;\n\n /** Development dependencies of all projects. */\n devDependencies: WorkspaceDependencies<M> = [] as unknown as WorkspaceDependencies<M>;\n\n /** All dependencies of all projects and workspace dependencies. */\n allDependencies: WorkspaceDependencies<M> = [] as unknown as WorkspaceDependencies<M>;\n\n /** Versions of each dependency. */\n dependencyVersions: Record<string, string[]> = {};\n\n /** Errors found during reading from the file system. */\n errors: Array<InstanceType<typeof WorkspaceError>> = [];\n\n constructor(options: WorkspaceOptions<M>) {\n this.path = options.path;\n\n if (options.isMultiProject === undefined || options.isMultiProject) {\n this.isMultiProject = true as M;\n\n let projectGlobOption = (options as WorkspaceOptions<true>).projectGlobs;\n\n if (projectGlobOption) {\n this.projectGlobs = projectGlobOption as WorkspaceProjectGlobs<M>;\n } else {\n this.projectGlobs = [] as string[] as WorkspaceProjectGlobs<M>;\n }\n\n this.projects = [] as Array<Project<M>> as WorkspaceProjects<M>;\n\n let {projects} = options as WorkspaceOptions<true>;\n\n if (projects) {\n this.addProjects(projects.map((project) => new Project({...project, workspace: this})));\n }\n\n let packageJsonOption = (options as WorkspaceOptions<true>).packageJson;\n\n if (packageJsonOption) {\n this.packageJson = packageJsonOption as M extends true ? PackageJson : null;\n } else {\n let emptyPackageJson: PackageJson = {};\n\n this.packageJson = emptyPackageJson as M extends true ? PackageJson : null;\n }\n } else {\n this.isMultiProject = false as M;\n this.projectGlobs = null as M extends true ? string[] : null;\n this.packageJson = null as M extends true ? PackageJson : null;\n this.projects = [] as Array<Project<M>> as WorkspaceProjects<M>;\n\n let {projects} = options as WorkspaceOptions<false>;\n\n if (projects) {\n this.addProjects(projects.map((project) => new Project({...project, workspace: this})));\n }\n }\n\n let configOption = options.config;\n\n if (configOption) {\n this.config = configOption;\n } else {\n let emptyWorkspaceConfig: WorkspaceConfig = {};\n\n this.config = emptyWorkspaceConfig;\n }\n\n if (options.repository) {\n this.repository = options.repository;\n }\n\n if (options.errors) {\n this.errors = options.errors;\n }\n\n // add missing project globs\n if (this.isMultiProject && !(this.projectGlobs as string[]).length) {\n let packageJsonWorkspaces = getPackageJsonWorkspaces(this.packageJson as PackageJson);\n\n if (packageJsonWorkspaces) {\n this.projectGlobs = [...packageJsonWorkspaces] as M extends true ? string[] : null;\n }\n }\n\n this.sortProjects();\n this.updateDependencies();\n }\n\n /**\n * Creates new workspace within the file system.\n *\n * @param options Options.\n * @returns The new workspace.\n */\n static async create({args, path: workspacePath, templateId}: WorkspaceCreateOptions) {\n // TODO: test that workspace returned by this method has the same value of isMultiProject when the same workspace is after its creation re-read with .read()\n let workspace = new this({\n path: workspacePath,\n config: {\n template: templateId,\n },\n });\n\n try {\n await ensureEmptyDirectory(workspace.path, {allowGit: true});\n } catch {\n throw new WorkspaceError('WORKSPACE_PATH_NOT_EMPTY', {\n messageParameters: [workspace.path],\n data: {\n path: workspace.path,\n },\n });\n }\n\n let template = await readCarsonTemplate(templateId);\n let templateRenders = await renderCarsonTemplate({\n template,\n templateData: {\n workspace,\n args,\n },\n });\n\n if (!template.config.autoEject) {\n await saveWorkspaceConfig({\n workspacePath: workspace.path,\n workspaceConfig: {template: templateId},\n });\n }\n\n await applyTemplateRenders({\n templateRenders,\n targetPath: workspace.path,\n snapshotPath:\n template.config.autoEject ?\n undefined\n : path.join(workspace.path, CARSON_CONFIG_DIRECTORY, WORKSPACE_SNAPSHOT_FILENAME),\n ignoreStrategies: ['check'],\n });\n\n return Workspace.read(workspace.path);\n }\n\n static async read(workspacePath: string): Promise<Workspace | Workspace<false>> {\n let resolvedWorkspacePath = path.resolve(workspacePath);\n\n if (!(await fs.pathExists(resolvedWorkspacePath))) {\n throw new WorkspaceError('NO_SUCH_WORKSPACE_PATH', {\n messageParameters: [resolvedWorkspacePath],\n data: {\n path: resolvedWorkspacePath,\n },\n });\n }\n\n // load root package.json\n let rootPackageJsonPath = path.join(resolvedWorkspacePath, 'package.json');\n let doesRootPackageJsonExist = await fs.pathExists(rootPackageJsonPath);\n let rootPackageJson: PackageJson | z.ZodError;\n\n if (doesRootPackageJsonExist) {\n rootPackageJson = await readFile(rootPackageJsonPath, packageJsonSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n } else {\n rootPackageJson = {};\n }\n\n if (rootPackageJson instanceof z.ZodError) {\n rootPackageJson = {};\n\n // even if the package.json file has errors, maybe there's still a correct workspace field\n try {\n let rootJson = await readFile(rootPackageJsonPath, jsonSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n throwOnZodError: true,\n });\n let projectGlobs = getPackageJsonWorkspaces(rootJson);\n\n // add back to the empty package.json object\n if (projectGlobs) {\n rootPackageJson.workspaces = projectGlobs;\n }\n } catch {\n // no-op\n }\n }\n\n // load workspace config\n let workspaceConfigPath = path.join(\n resolvedWorkspacePath,\n CARSON_CONFIG_DIRECTORY,\n WORKSPACE_CONFIG_FILENAME,\n );\n let doesWorkspaceConfigExist = await fs.pathExists(workspaceConfigPath);\n let workspaceConfig: WorkspaceConfig | z.ZodError;\n\n if (doesWorkspaceConfigExist) {\n workspaceConfig = await readFile(workspaceConfigPath, workspaceConfigSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n } else {\n workspaceConfig = {};\n }\n\n if (workspaceConfig instanceof z.ZodError) {\n workspaceConfig = {};\n }\n\n // how to find projects\n let packageJsonProjectGlobs = getPackageJsonWorkspaces(rootPackageJson);\n let workspaceConfigProjectGlobs = workspaceConfig.projects;\n\n if (\n packageJsonProjectGlobs?.length &&\n workspaceConfigProjectGlobs?.length &&\n !_.isEqual(packageJsonProjectGlobs, workspaceConfigProjectGlobs)\n ) {\n throw new WorkspaceError('PROJECT_GLOBS_MISMATCH', {\n data: {\n path: resolvedWorkspacePath,\n },\n });\n }\n\n let projectGlobs = packageJsonProjectGlobs ?? workspaceConfigProjectGlobs;\n\n // we're dealing with single-project workspace\n if (!projectGlobs) {\n let workspace = new this({\n path: resolvedWorkspacePath,\n isMultiProject: false,\n });\n\n await workspace.read();\n await workspace.readProjects();\n\n return workspace;\n }\n\n // we're dealing with multi-project workspace\n let workspace = new this({\n path: resolvedWorkspacePath,\n isMultiProject: true,\n projectGlobs,\n packageJson: rootPackageJson,\n });\n\n await workspace.read();\n await workspace.readProjects();\n\n return workspace;\n }\n\n /**\n * Traverses file system up from the search path and tries to find a directory that is a root of a workspace.\n *\n * @param searchPath Search path.\n * @returns Workspace path, if found.\n */\n static async find(searchPath: string): Promise<string | undefined> {\n let startingPath = await findExistingDirectory(path.resolve(searchPath));\n let currentPath = startingPath;\n let singlePackageWorkspacePath: string | undefined;\n let multiPackageWorkspacePath: string | undefined;\n\n while (\n !(isRootPath(currentPath) || (singlePackageWorkspacePath && multiPackageWorkspacePath))\n ) {\n if (await containsWorkspace(currentPath)) {\n let packageJsonPath = path.join(currentPath, PACKAGE_JSON_FILENAME);\n let workspaceConfigPath = path.join(\n currentPath,\n CARSON_CONFIG_DIRECTORY,\n WORKSPACE_CONFIG_FILENAME,\n );\n\n if (await fs.pathExists(packageJsonPath)) {\n let packageJson = await readFile(packageJsonPath, jsonSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n\n if (!(packageJson instanceof Error)) {\n let projectGlobs = getPackageJsonWorkspaces(packageJson);\n\n if (projectGlobs?.length) {\n multiPackageWorkspacePath ??= currentPath;\n } else {\n singlePackageWorkspacePath ??= currentPath;\n }\n }\n }\n if (await fs.pathExists(workspaceConfigPath)) {\n let workspaceConfig = await readFile(workspaceConfigPath, workspaceConfigSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n\n if (!(workspaceConfig instanceof z.ZodError)) {\n let projectGlobs = workspaceConfig.projects;\n\n if (projectGlobs?.length) {\n multiPackageWorkspacePath ??= currentPath;\n } else {\n singlePackageWorkspacePath ??= currentPath;\n }\n }\n } else {\n singlePackageWorkspacePath ??= currentPath;\n }\n }\n\n currentPath = path.dirname(currentPath);\n }\n\n if (multiPackageWorkspacePath) {\n return multiPackageWorkspacePath;\n } else if (singlePackageWorkspacePath) {\n return singlePackageWorkspacePath;\n }\n\n return undefined;\n }\n\n /**\n * Traverses file system up from the search path and tries to find and read a workspace.\n */\n static async findAndRead<O extends WorkspaceFindAndReadOptions | undefined = undefined>(\n searchPath: string,\n options?: O,\n ): Promise<\n O extends undefined ? Workspace | Workspace<false> | undefined\n : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>\n : Workspace | Workspace<false> | undefined\n > {\n let workspacePath = await Workspace.find(searchPath);\n\n if (workspacePath) {\n return Workspace.read(workspacePath) as Promise<\n O extends undefined ? Workspace | Workspace<false> | undefined\n : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>\n : Workspace | Workspace<false> | undefined\n >;\n } else if (options?.throwIfNotFound) {\n throw new WorkspaceError('NO_WORKSPACE_FOUND', {\n messageParameters: [searchPath],\n data: {\n path: searchPath,\n },\n });\n }\n\n return undefined as unknown as Promise<\n O extends undefined ? Workspace | Workspace<false> | undefined\n : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>\n : Workspace | Workspace<false> | undefined\n >;\n }\n\n async read(): Promise<this> {\n if (!(await fs.pathExists(this.path))) {\n throw new WorkspaceError('NO_SUCH_WORKSPACE_PATH', {\n messageParameters: [this.path],\n data: {\n path: this.path,\n },\n });\n }\n\n let errors: Array<InstanceType<typeof WorkspaceError>> = [];\n let repositoryUrl = await getRepositoryUrl(this.path);\n let repositoryBranches = await getRepositoryBranches(this.path);\n\n // load workspace config\n let workspaceConfigPath = path.join(\n this.path,\n CARSON_CONFIG_DIRECTORY,\n WORKSPACE_CONFIG_FILENAME,\n );\n let doesWorkspaceConfigExist = await fs.pathExists(workspaceConfigPath);\n let workspaceConfig: WorkspaceConfig | z.ZodError;\n\n if (doesWorkspaceConfigExist) {\n workspaceConfig = await readFile(workspaceConfigPath, workspaceConfigSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n } else {\n workspaceConfig = {};\n }\n\n if (workspaceConfig instanceof z.ZodError) {\n let zodError = workspaceConfig;\n let workspaceError = new WorkspaceError('INVALID_WORKSPACE_CONFIG', {\n messageParameters: [workspaceConfigPath],\n data: {\n path: workspaceConfigPath,\n zodIssues: zodError.issues,\n },\n });\n\n errors.push(workspaceError);\n\n workspaceConfig = {};\n }\n\n if (this.isMultiProject) {\n // load root package.json\n let rootPackageJsonPath = path.join(this.path, 'package.json');\n let doesRootPackageJsonExist = await fs.pathExists(rootPackageJsonPath);\n let rootPackageJson: PackageJson | z.ZodError;\n\n if (doesRootPackageJsonExist) {\n rootPackageJson = await readFile(rootPackageJsonPath, packageJsonSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n } else {\n rootPackageJson = {};\n }\n\n if (rootPackageJson instanceof z.ZodError) {\n let zodError = rootPackageJson;\n let workspaceError = new WorkspaceError('INVALID_PACKAGE_JSON', {\n messageParameters: [rootPackageJsonPath],\n data: {\n path: rootPackageJsonPath,\n zodIssues: zodError.issues,\n },\n });\n\n errors.push(workspaceError);\n\n rootPackageJson = {};\n }\n\n // how to find projects\n let packageJsonProjectGlobs = getPackageJsonWorkspaces(rootPackageJson);\n let workspaceConfigProjectGlobs = workspaceConfig.projects;\n\n if (\n packageJsonProjectGlobs &&\n workspaceConfigProjectGlobs &&\n !_.isEqual(packageJsonProjectGlobs, workspaceConfigProjectGlobs)\n ) {\n throw new WorkspaceError('PROJECT_GLOBS_MISMATCH', {\n data: {\n path: this.path,\n },\n });\n }\n\n let projectGlobs = packageJsonProjectGlobs ?? workspaceConfigProjectGlobs;\n\n this.projectGlobs = (projectGlobs ?? []) as WorkspaceProjectGlobs<M>;\n this.packageJson = rootPackageJson as WorkspacePackageJson<M>;\n this.config = workspaceConfig;\n this.errors = errors;\n\n if (repositoryUrl) {\n this.repository = {\n url: repositoryUrl,\n branches: repositoryBranches ?? [],\n };\n } else if (repositoryBranches) {\n this.repository = {\n branches: repositoryBranches,\n };\n }\n\n await this.readProjects();\n\n return this;\n }\n\n // we're dealing with single-project workspace\n this.config = workspaceConfig;\n this.errors = errors;\n\n if (repositoryUrl) {\n this.repository = {\n url: repositoryUrl,\n branches: repositoryBranches ?? [],\n };\n } else if (repositoryBranches) {\n this.repository = {\n branches: repositoryBranches,\n };\n }\n\n await this.readProjects();\n\n return this;\n }\n\n async update({args}: WorkspaceUpdateOptions): Promise<this> {\n if (!this.config.template) {\n throw new WorkspaceError('MISSING_CARSON_TEMPLATE_ID', {\n messageParameters: [\n path.join(this.path, CARSON_CONFIG_DIRECTORY, WORKSPACE_CONFIG_FILENAME),\n ],\n });\n }\n\n let template = await readCarsonTemplate(this.config.template);\n let templateRenders = await renderCarsonTemplate({\n template,\n templateData: {\n workspace: this,\n args,\n },\n });\n\n await applyTemplateRenders({\n templateRenders,\n targetPath: this.path,\n snapshotPath:\n template.config.autoEject ?\n undefined\n : path.join(this.path, CARSON_CONFIG_DIRECTORY, WORKSPACE_SNAPSHOT_FILENAME),\n ignoreStrategies: ['create'],\n });\n\n await this.read();\n\n return this;\n }\n\n getProject(projectName: Project<M> | string): Project<M> | undefined {\n for (let project of this.projects) {\n if (project.name === projectName || project === projectName) {\n return project;\n }\n }\n\n return undefined;\n }\n\n async createProject({\n templateId,\n projectPath,\n projectName,\n args,\n }: WorkspaceCreateProjectOptions): Promise<Project<M>> {\n let resolvedProjectPath = path.resolve(projectPath);\n\n if (this.projects.some((project) => resolvedProjectPath === project.path)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_PATH', {\n messageParameters: [resolvedProjectPath],\n });\n }\n\n if (this.projects.some((project) => projectName === project.name)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_NAME', {messageParameters: [projectName]});\n }\n\n if (!this.isMultiProject && this.projects.length >= 1) {\n throw new WorkspaceError('TOO_MANY_PROJECTS');\n }\n\n if (!this.isMultiProject && projectPath !== this.path) {\n throw new WorkspaceError('PATH_MISMATCH');\n }\n\n let newProject = await Project.create({\n templateId,\n projectPath,\n projectName,\n args,\n workspace: this,\n });\n\n this.addProject(newProject);\n\n return newProject;\n }\n\n addProject(newProject: Project<M>): this {\n if (this.projects.some((project) => newProject.path === project.path)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_PATH', {\n messageParameters: [newProject.path],\n });\n }\n\n if (this.projects.some((project) => newProject.name === project.name)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_NAME', {messageParameters: [newProject.name]});\n }\n\n if (!this.isMultiProject && this.projects.length >= 1) {\n throw new WorkspaceError('TOO_MANY_PROJECTS');\n }\n\n if (!this.isMultiProject && newProject.path !== this.path) {\n throw new WorkspaceError('PATH_MISMATCH');\n }\n\n this.projects.push(newProject);\n this.sortProjects();\n this.updateDependencies();\n\n return this;\n }\n\n addProjects(newProjects: Array<Project<M>>): this {\n for (let newProject of newProjects) {\n if (this.projects.some((project) => newProject.path === project.path)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_PATH', {\n messageParameters: [newProject.path],\n });\n }\n\n if (this.projects.some((project) => newProject.name === project.name)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_NAME', {messageParameters: [newProject.name]});\n }\n\n if (!this.isMultiProject && this.projects.length >= 1) {\n throw new WorkspaceError('TOO_MANY_PROJECTS');\n }\n\n if (!this.isMultiProject && newProject.path !== this.path) {\n throw new WorkspaceError('PATH_MISMATCH');\n }\n\n this.projects.push(newProject);\n }\n\n this.sortProjects();\n this.updateDependencies();\n\n return this;\n }\n\n async readProjects(): Promise<Array<Project<M>>> {\n if (this.projectGlobs) {\n let projects: Array<Project<M>> = [];\n let packagePaths = await glob(this.projectGlobs, {\n cwd: this.path,\n onlyDirectories: true,\n });\n\n for (let packagePath of packagePaths) {\n let projectPath = path.join(this.path, packagePath);\n\n if (await containsProject(projectPath)) {\n let project = await Project.read(projectPath, this);\n\n projects.push(project);\n }\n }\n\n this.projects = projects;\n\n this.sortProjects();\n this.updateDependencies();\n } else if (await containsProject(this.path)) {\n this.projects = [await Project.read(this.path, this)];\n\n this.sortProjects();\n this.updateDependencies();\n }\n\n return this.projects;\n }\n\n protected sortProjects(): void {\n this.projects.sort(compareProjectPath);\n }\n\n protected updateDependencies(): void {\n this.dependencies = WorkspaceDependencies.fromWorkspace(this);\n this.devDependencies = WorkspaceDependencies.fromWorkspace(this, {\n includeOnlyDevDependencies: true,\n });\n this.allDependencies = WorkspaceDependencies.fromWorkspace(this, {\n includeDevDependencies: true,\n includeWorkspaceDependencies: true,\n });\n this.dependencyVersions = this.allDependencies.getVersions({\n useExactVersions: true,\n });\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import {ensureEmptyDirectory, findExistingDirectory, isRootPath} from '@jakubmazanec/fs-utils';\nimport {jsonSchema, type PackageJson, packageJsonSchema, readFile} from '@jakubmazanec/zod-utils';\nimport glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport json5 from 'json5';\nimport _ from 'lodash';\nimport path from 'node:path';\nimport {z} from 'zod';\n\nimport {\n CARSON_CONFIG_DIRECTORY,\n PACKAGE_JSON_FILENAME,\n WORKSPACE_CONFIG_FILENAME,\n WORKSPACE_SNAPSHOT_FILENAME,\n} from '../constants.js';\nimport {applyTemplateRenders} from '../template/applyTemplateRenders.js';\nimport {readCarsonTemplate} from '../template/internals.js';\nimport {renderCarsonTemplate} from '../template/renderCarsonTemplate.js';\nimport {\n compareProjectPath,\n containsProject,\n containsWorkspace,\n getPackageJsonWorkspaces,\n getRepositoryBranches,\n getRepositoryUrl,\n} from './internals.js';\nimport {Project} from './Project.js';\nimport {saveWorkspaceConfig} from './saveWorkspaceConfig.js';\nimport {workspaceConfigSchema} from './WorkspaceConfig.js';\nimport {type WorkspaceConfig} from './WorkspaceConfig.js';\nimport {type WorkspaceCreateOptions} from './WorkspaceCreateOptions.js';\nimport {type WorkspaceCreateProjectOptions} from './WorkspaceCreateProjectOptions.js';\nimport {WorkspaceDependencies} from './WorkspaceDependencies.js';\nimport {WorkspaceError} from './WorkspaceError.js';\nimport {type WorkspaceFindAndReadOptions} from './WorkspaceFindAndReadOptions.js';\nimport {type WorkspaceOptions} from './WorkspaceOptions.js';\nimport {type WorkspacePackageJson} from './WorkspacePackageJson.js';\nimport {type WorkspaceProjectGlobs} from './WorkspaceProjectGlobs.js';\nimport {type WorkspaceProjects} from './WorkspaceProjects.js';\nimport {type WorkspaceRepository} from './WorkspaceRepository.js';\nimport {type WorkspaceUpdateOptions} from './WorkspaceUpdateOptions.js';\n\n/**\n * Workspace represent a directory, usually a git repository, that contains {@link Project} instances.\n *\n * @typeParam M If true, the workspace is multi-project workspace (so-called \"monorepo\").\n */\nexport class Workspace<M extends boolean = true> {\n /** Workspace path. */\n readonly path: string;\n\n /** Does the workspace contain a multiple projects? */\n readonly isMultiProject: M;\n\n /** Globs used to find projects. */\n projectGlobs: WorkspaceProjectGlobs<M>;\n\n /** Workspace projects. */\n projects: WorkspaceProjects<M>;\n\n /** Workspace configuration; if it's not found, the default is an empty object. */\n config: WorkspaceConfig;\n\n /** Parsed workspace `package.json` file (if the workspace contains multiple projects); if it's not found, the default is an empty object. */\n packageJson: WorkspacePackageJson<M>;\n\n /** Workspace git repository. */\n repository?: WorkspaceRepository;\n\n /** Dependencies of all projects. */\n dependencies: WorkspaceDependencies<M> = [] as unknown as WorkspaceDependencies<M>;\n\n /** Development dependencies of all projects. */\n devDependencies: WorkspaceDependencies<M> = [] as unknown as WorkspaceDependencies<M>;\n\n /** All dependencies of all projects and workspace dependencies. */\n allDependencies: WorkspaceDependencies<M> = [] as unknown as WorkspaceDependencies<M>;\n\n /** Versions of each dependency. */\n dependencyVersions: Record<string, string[]> = {};\n\n /** Errors found during reading from the file system. */\n errors: Array<InstanceType<typeof WorkspaceError>> = [];\n\n constructor(options: WorkspaceOptions<M>) {\n this.path = options.path;\n\n if (options.isMultiProject === undefined || options.isMultiProject) {\n this.isMultiProject = true as M;\n\n let projectGlobOption = (options as WorkspaceOptions<true>).projectGlobs;\n\n if (projectGlobOption) {\n this.projectGlobs = projectGlobOption as WorkspaceProjectGlobs<M>;\n } else {\n this.projectGlobs = [] as string[] as WorkspaceProjectGlobs<M>;\n }\n\n this.projects = [] as Array<Project<M>> as WorkspaceProjects<M>;\n\n let {projects} = options as WorkspaceOptions<true>;\n\n if (projects) {\n this.addProjects(projects.map((project) => new Project({...project, workspace: this})));\n }\n\n let packageJsonOption = (options as WorkspaceOptions<true>).packageJson;\n\n if (packageJsonOption) {\n this.packageJson = packageJsonOption as M extends true ? PackageJson : null;\n } else {\n let emptyPackageJson: PackageJson = {};\n\n this.packageJson = emptyPackageJson as M extends true ? PackageJson : null;\n }\n } else {\n this.isMultiProject = false as M;\n this.projectGlobs = null as M extends true ? string[] : null;\n this.packageJson = null as M extends true ? PackageJson : null;\n this.projects = [] as Array<Project<M>> as WorkspaceProjects<M>;\n\n let {projects} = options as WorkspaceOptions<false>;\n\n if (projects) {\n this.addProjects(projects.map((project) => new Project({...project, workspace: this})));\n }\n }\n\n let configOption = options.config;\n\n if (configOption) {\n this.config = configOption;\n } else {\n let emptyWorkspaceConfig: WorkspaceConfig = {};\n\n this.config = emptyWorkspaceConfig;\n }\n\n if (options.repository) {\n this.repository = options.repository;\n }\n\n if (options.errors) {\n this.errors = options.errors;\n }\n\n // add missing project globs\n if (this.isMultiProject && !(this.projectGlobs as string[]).length) {\n let packageJsonWorkspaces = getPackageJsonWorkspaces(this.packageJson as PackageJson);\n\n if (packageJsonWorkspaces) {\n this.projectGlobs = [...packageJsonWorkspaces] as M extends true ? string[] : null;\n }\n }\n\n this.sortProjects();\n this.updateDependencies();\n }\n\n /**\n * Creates new workspace within the file system.\n *\n * @param options Options.\n * @returns The new workspace.\n */\n static async create({args, path: workspacePath, templateId}: WorkspaceCreateOptions) {\n // TODO: test that workspace returned by this method has the same value of isMultiProject when the same workspace is after its creation re-read with .read()\n let workspace = new this({\n path: workspacePath,\n config: {\n template: templateId,\n },\n });\n\n try {\n await ensureEmptyDirectory(workspace.path, {allowGit: true});\n } catch {\n throw new WorkspaceError('WORKSPACE_PATH_NOT_EMPTY', {\n messageParameters: [workspace.path],\n data: {\n path: workspace.path,\n },\n });\n }\n\n let template = await readCarsonTemplate(templateId);\n let templateRenders = await renderCarsonTemplate({\n template,\n templateData: {\n workspace,\n args,\n },\n });\n\n if (!template.config.autoEject) {\n await saveWorkspaceConfig({\n workspacePath: workspace.path,\n workspaceConfig: {template: templateId},\n });\n }\n\n await applyTemplateRenders({\n templateRenders,\n targetPath: workspace.path,\n snapshotPath:\n template.config.autoEject ?\n undefined\n : path.join(workspace.path, CARSON_CONFIG_DIRECTORY, WORKSPACE_SNAPSHOT_FILENAME),\n ignoreStrategies: ['check'],\n });\n\n return Workspace.read(workspace.path);\n }\n\n static async read(workspacePath: string): Promise<Workspace | Workspace<false>> {\n let resolvedWorkspacePath = path.resolve(workspacePath);\n\n if (!(await fs.pathExists(resolvedWorkspacePath))) {\n throw new WorkspaceError('NO_SUCH_WORKSPACE_PATH', {\n messageParameters: [resolvedWorkspacePath],\n data: {\n path: resolvedWorkspacePath,\n },\n });\n }\n\n // load root package.json\n let rootPackageJsonPath = path.join(resolvedWorkspacePath, 'package.json');\n let doesRootPackageJsonExist = await fs.pathExists(rootPackageJsonPath);\n let rootPackageJson: PackageJson | z.ZodError;\n\n if (doesRootPackageJsonExist) {\n rootPackageJson = await readFile(rootPackageJsonPath, packageJsonSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n } else {\n rootPackageJson = {};\n }\n\n if (rootPackageJson instanceof z.ZodError) {\n rootPackageJson = {};\n\n // even if the package.json file has errors, maybe there's still a correct workspace field\n try {\n let rootJson = await readFile(rootPackageJsonPath, jsonSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n throwOnZodError: true,\n });\n let projectGlobs = getPackageJsonWorkspaces(rootJson);\n\n // add back to the empty package.json object\n if (projectGlobs) {\n rootPackageJson.workspaces = projectGlobs;\n }\n } catch {\n // no-op\n }\n }\n\n // load workspace config\n let workspaceConfigPath = path.join(\n resolvedWorkspacePath,\n CARSON_CONFIG_DIRECTORY,\n WORKSPACE_CONFIG_FILENAME,\n );\n let doesWorkspaceConfigExist = await fs.pathExists(workspaceConfigPath);\n let workspaceConfig: WorkspaceConfig | z.ZodError;\n\n if (doesWorkspaceConfigExist) {\n workspaceConfig = await readFile(workspaceConfigPath, workspaceConfigSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n } else {\n workspaceConfig = {};\n }\n\n if (workspaceConfig instanceof z.ZodError) {\n workspaceConfig = {};\n }\n\n // how to find projects\n let packageJsonProjectGlobs = getPackageJsonWorkspaces(rootPackageJson);\n let workspaceConfigProjectGlobs = workspaceConfig.projects;\n\n if (\n packageJsonProjectGlobs?.length &&\n workspaceConfigProjectGlobs?.length &&\n !_.isEqual(packageJsonProjectGlobs, workspaceConfigProjectGlobs)\n ) {\n throw new WorkspaceError('PROJECT_GLOBS_MISMATCH', {\n data: {\n path: resolvedWorkspacePath,\n },\n });\n }\n\n let projectGlobs = packageJsonProjectGlobs ?? workspaceConfigProjectGlobs;\n\n // we're dealing with single-project workspace\n if (!projectGlobs) {\n let workspace = new this({\n path: resolvedWorkspacePath,\n isMultiProject: false,\n });\n\n await workspace.read();\n await workspace.readProjects();\n\n return workspace;\n }\n\n // we're dealing with multi-project workspace\n let workspace = new this({\n path: resolvedWorkspacePath,\n isMultiProject: true,\n projectGlobs,\n packageJson: rootPackageJson,\n });\n\n await workspace.read();\n await workspace.readProjects();\n\n return workspace;\n }\n\n /**\n * Traverses file system up from the search path and tries to find a directory that is a root of a workspace.\n *\n * @param searchPath Search path.\n * @returns Workspace path, if found.\n */\n static async find(searchPath: string): Promise<string | undefined> {\n let startingPath = await findExistingDirectory(path.resolve(searchPath));\n let currentPath = startingPath;\n let singlePackageWorkspacePath: string | undefined;\n let multiPackageWorkspacePath: string | undefined;\n\n while (\n !(isRootPath(currentPath) || (singlePackageWorkspacePath && multiPackageWorkspacePath))\n ) {\n if (await containsWorkspace(currentPath)) {\n let packageJsonPath = path.join(currentPath, PACKAGE_JSON_FILENAME);\n let workspaceConfigPath = path.join(\n currentPath,\n CARSON_CONFIG_DIRECTORY,\n WORKSPACE_CONFIG_FILENAME,\n );\n\n if (await fs.pathExists(packageJsonPath)) {\n let packageJson = await readFile(packageJsonPath, jsonSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n\n if (!(packageJson instanceof Error)) {\n let projectGlobs = getPackageJsonWorkspaces(packageJson);\n\n if (projectGlobs?.length) {\n multiPackageWorkspacePath ??= currentPath;\n } else {\n singlePackageWorkspacePath ??= currentPath;\n }\n }\n }\n if (await fs.pathExists(workspaceConfigPath)) {\n let workspaceConfig = await readFile(workspaceConfigPath, workspaceConfigSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n\n if (!(workspaceConfig instanceof z.ZodError)) {\n let projectGlobs = workspaceConfig.projects;\n\n if (projectGlobs?.length) {\n multiPackageWorkspacePath ??= currentPath;\n } else {\n singlePackageWorkspacePath ??= currentPath;\n }\n }\n } else {\n singlePackageWorkspacePath ??= currentPath;\n }\n }\n\n currentPath = path.dirname(currentPath);\n }\n\n if (multiPackageWorkspacePath) {\n return multiPackageWorkspacePath;\n } else if (singlePackageWorkspacePath) {\n return singlePackageWorkspacePath;\n }\n\n return undefined;\n }\n\n /**\n * Traverses file system up from the search path and tries to find and read a workspace.\n */\n static async findAndRead<O extends undefined | WorkspaceFindAndReadOptions = undefined>(\n searchPath: string,\n options?: O,\n ): Promise<\n O extends undefined ? undefined | Workspace | Workspace<false>\n : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>\n : undefined | Workspace | Workspace<false>\n > {\n let workspacePath = await Workspace.find(searchPath);\n\n if (workspacePath) {\n return Workspace.read(workspacePath) as Promise<\n O extends undefined ? undefined | Workspace | Workspace<false>\n : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>\n : undefined | Workspace | Workspace<false>\n >;\n } else if (options?.throwIfNotFound) {\n throw new WorkspaceError('NO_WORKSPACE_FOUND', {\n messageParameters: [searchPath],\n data: {\n path: searchPath,\n },\n });\n }\n\n return undefined as unknown as Promise<\n O extends undefined ? undefined | Workspace | Workspace<false>\n : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>\n : undefined | Workspace | Workspace<false>\n >;\n }\n\n async read(): Promise<this> {\n if (!(await fs.pathExists(this.path))) {\n throw new WorkspaceError('NO_SUCH_WORKSPACE_PATH', {\n messageParameters: [this.path],\n data: {\n path: this.path,\n },\n });\n }\n\n let errors: Array<InstanceType<typeof WorkspaceError>> = [];\n let repositoryUrl = await getRepositoryUrl(this.path);\n let repositoryBranches = await getRepositoryBranches(this.path);\n\n // load workspace config\n let workspaceConfigPath = path.join(\n this.path,\n CARSON_CONFIG_DIRECTORY,\n WORKSPACE_CONFIG_FILENAME,\n );\n let doesWorkspaceConfigExist = await fs.pathExists(workspaceConfigPath);\n let workspaceConfig: WorkspaceConfig | z.ZodError;\n\n if (doesWorkspaceConfigExist) {\n workspaceConfig = await readFile(workspaceConfigPath, workspaceConfigSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n } else {\n workspaceConfig = {};\n }\n\n if (workspaceConfig instanceof z.ZodError) {\n let zodError = workspaceConfig;\n let workspaceError = new WorkspaceError('INVALID_WORKSPACE_CONFIG', {\n messageParameters: [workspaceConfigPath],\n data: {\n path: workspaceConfigPath,\n zodIssues: zodError.issues,\n },\n });\n\n errors.push(workspaceError);\n\n workspaceConfig = {};\n }\n\n if (this.isMultiProject) {\n // load root package.json\n let rootPackageJsonPath = path.join(this.path, 'package.json');\n let doesRootPackageJsonExist = await fs.pathExists(rootPackageJsonPath);\n let rootPackageJson: PackageJson | z.ZodError;\n\n if (doesRootPackageJsonExist) {\n rootPackageJson = await readFile(rootPackageJsonPath, packageJsonSchema, {\n parser: (rawString: string) => json5.parse<unknown>(rawString),\n });\n } else {\n rootPackageJson = {};\n }\n\n if (rootPackageJson instanceof z.ZodError) {\n let zodError = rootPackageJson;\n let workspaceError = new WorkspaceError('INVALID_PACKAGE_JSON', {\n messageParameters: [rootPackageJsonPath],\n data: {\n path: rootPackageJsonPath,\n zodIssues: zodError.issues,\n },\n });\n\n errors.push(workspaceError);\n\n rootPackageJson = {};\n }\n\n // how to find projects\n let packageJsonProjectGlobs = getPackageJsonWorkspaces(rootPackageJson);\n let workspaceConfigProjectGlobs = workspaceConfig.projects;\n\n if (\n packageJsonProjectGlobs &&\n workspaceConfigProjectGlobs &&\n !_.isEqual(packageJsonProjectGlobs, workspaceConfigProjectGlobs)\n ) {\n throw new WorkspaceError('PROJECT_GLOBS_MISMATCH', {\n data: {\n path: this.path,\n },\n });\n }\n\n let projectGlobs = packageJsonProjectGlobs ?? workspaceConfigProjectGlobs;\n\n this.projectGlobs = (projectGlobs ?? []) as WorkspaceProjectGlobs<M>;\n this.packageJson = rootPackageJson as WorkspacePackageJson<M>;\n this.config = workspaceConfig;\n this.errors = errors;\n\n if (repositoryUrl) {\n this.repository = {\n url: repositoryUrl,\n branches: repositoryBranches ?? [],\n };\n } else if (repositoryBranches) {\n this.repository = {\n branches: repositoryBranches,\n };\n }\n\n await this.readProjects();\n\n return this;\n }\n\n // we're dealing with single-project workspace\n this.config = workspaceConfig;\n this.errors = errors;\n\n if (repositoryUrl) {\n this.repository = {\n url: repositoryUrl,\n branches: repositoryBranches ?? [],\n };\n } else if (repositoryBranches) {\n this.repository = {\n branches: repositoryBranches,\n };\n }\n\n await this.readProjects();\n\n return this;\n }\n\n async update({args}: WorkspaceUpdateOptions): Promise<this> {\n if (!this.config.template) {\n throw new WorkspaceError('MISSING_CARSON_TEMPLATE_ID', {\n messageParameters: [\n path.join(this.path, CARSON_CONFIG_DIRECTORY, WORKSPACE_CONFIG_FILENAME),\n ],\n });\n }\n\n let template = await readCarsonTemplate(this.config.template);\n let templateRenders = await renderCarsonTemplate({\n template,\n templateData: {\n workspace: this,\n args,\n },\n });\n\n await applyTemplateRenders({\n templateRenders,\n targetPath: this.path,\n snapshotPath:\n template.config.autoEject ?\n undefined\n : path.join(this.path, CARSON_CONFIG_DIRECTORY, WORKSPACE_SNAPSHOT_FILENAME),\n ignoreStrategies: ['create'],\n });\n\n await this.read();\n\n return this;\n }\n\n getProject(projectName: Project<M> | string): Project<M> | undefined {\n for (let project of this.projects) {\n if (project.name === projectName || project === projectName) {\n return project;\n }\n }\n\n return undefined;\n }\n\n async createProject({\n templateId,\n projectPath,\n projectName,\n args,\n }: WorkspaceCreateProjectOptions): Promise<Project<M>> {\n let resolvedProjectPath = path.resolve(projectPath);\n\n if (this.projects.some((project) => resolvedProjectPath === project.path)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_PATH', {\n messageParameters: [resolvedProjectPath],\n });\n }\n\n if (this.projects.some((project) => projectName === project.name)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_NAME', {messageParameters: [projectName]});\n }\n\n if (!this.isMultiProject && this.projects.length >= 1) {\n throw new WorkspaceError('TOO_MANY_PROJECTS');\n }\n\n if (!this.isMultiProject && projectPath !== this.path) {\n throw new WorkspaceError('PATH_MISMATCH');\n }\n\n let newProject = await Project.create({\n templateId,\n projectPath,\n projectName,\n args,\n workspace: this,\n });\n\n this.addProject(newProject);\n\n return newProject;\n }\n\n addProject(newProject: Project<M>): this {\n if (this.projects.some((project) => newProject.path === project.path)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_PATH', {\n messageParameters: [newProject.path],\n });\n }\n\n if (this.projects.some((project) => newProject.name === project.name)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_NAME', {messageParameters: [newProject.name]});\n }\n\n if (!this.isMultiProject && this.projects.length >= 1) {\n throw new WorkspaceError('TOO_MANY_PROJECTS');\n }\n\n if (!this.isMultiProject && newProject.path !== this.path) {\n throw new WorkspaceError('PATH_MISMATCH');\n }\n\n this.projects.push(newProject);\n this.sortProjects();\n this.updateDependencies();\n\n return this;\n }\n\n addProjects(newProjects: Array<Project<M>>): this {\n for (let newProject of newProjects) {\n if (this.projects.some((project) => newProject.path === project.path)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_PATH', {\n messageParameters: [newProject.path],\n });\n }\n\n if (this.projects.some((project) => newProject.name === project.name)) {\n throw new WorkspaceError('DUPLICATE_PROJECT_NAME', {messageParameters: [newProject.name]});\n }\n\n if (!this.isMultiProject && this.projects.length >= 1) {\n throw new WorkspaceError('TOO_MANY_PROJECTS');\n }\n\n if (!this.isMultiProject && newProject.path !== this.path) {\n throw new WorkspaceError('PATH_MISMATCH');\n }\n\n this.projects.push(newProject);\n }\n\n this.sortProjects();\n this.updateDependencies();\n\n return this;\n }\n\n async readProjects(): Promise<Array<Project<M>>> {\n if (this.projectGlobs) {\n let projects: Array<Project<M>> = [];\n let packagePaths = await glob(this.projectGlobs, {\n cwd: this.path,\n onlyDirectories: true,\n });\n\n for (let packagePath of packagePaths) {\n let projectPath = path.join(this.path, packagePath);\n\n if (await containsProject(projectPath)) {\n let project = await Project.read(projectPath, this);\n\n projects.push(project);\n }\n }\n\n this.projects = projects;\n\n this.sortProjects();\n this.updateDependencies();\n } else if (await containsProject(this.path)) {\n this.projects = [await Project.read(this.path, this)];\n\n this.sortProjects();\n this.updateDependencies();\n }\n\n return this.projects;\n }\n\n protected sortProjects(): void {\n this.projects.sort(compareProjectPath);\n }\n\n protected updateDependencies(): void {\n this.dependencies = WorkspaceDependencies.fromWorkspace(this);\n this.devDependencies = WorkspaceDependencies.fromWorkspace(this, {\n includeOnlyDevDependencies: true,\n });\n this.allDependencies = WorkspaceDependencies.fromWorkspace(this, {\n includeDevDependencies: true,\n includeWorkspaceDependencies: true,\n });\n this.dependencyVersions = this.allDependencies.getVersions({\n useExactVersions: true,\n });\n }\n}\n"],
|
|
5
5
|
"mappings": ";AAAA,SAAQ,sBAAsB,uBAAuB,kBAAiB;AACtE,SAAQ,YAA8B,mBAAmB,gBAAe;AACxE,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,WAAW;AAClB,OAAO,OAAO;AACd,OAAO,UAAU;AACjB,SAAQ,SAAQ;AAEhB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAQ,4BAA2B;AACnC,SAAQ,0BAAyB;AACjC,SAAQ,4BAA2B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAQ,eAAc;AACtB,SAAQ,2BAA0B;AAClC,SAAQ,6BAA4B;AAIpC,SAAQ,6BAA4B;AACpC,SAAQ,sBAAqB;AActB,aAAM,UAAoC;AAAA;AAAA,EAEtC;AAAA;AAAA,EAGA;AAAA;AAAA,EAGT;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA,eAAyC,CAAC;AAAA;AAAA,EAG1C,kBAA4C,CAAC;AAAA;AAAA,EAG7C,kBAA4C,CAAC;AAAA;AAAA,EAG7C,qBAA+C,C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,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/workspace/WorkspaceDependencies.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import _ from 'lodash';\nimport semver from 'semver';\n\nimport {compareSemver, compareWorkspaceDependencyProjectName} from './internals.js';\nimport {type Workspace} from './Workspace.js';\nimport {type WorkspaceDependenciesFromWorkspaceOptions} from './WorkspaceDependenciesFromWorkspaceOptions.js';\nimport {type WorkspaceDependenciesGetVersionsOptions} from './WorkspaceDependenciesGetVersionsOptions.js';\nimport {type WorkspaceDependency} from './WorkspaceDependency.js';\n\n/**\n * A collection of {@link WorkspaceDependency | workspace dependencies} that are installed in {@link Workspace | a workspace}.\n */\nexport class WorkspaceDependencies<M extends boolean = true> extends Array<WorkspaceDependency> {\n /** The workspace the dependencies are installed in. */\n workspace: Workspace<M>;\n\n constructor(...args: [...WorkspaceDependency[], Workspace<M>]) {\n super();\n\n if (args.length === 1) {\n [this.workspace] = args as [Workspace<M>];\n } else {\n let values = args.slice(0, -1) as WorkspaceDependency[];\n let workspace = args.at(-1) as Workspace<M>;\n\n this.push(...values);\n\n this.workspace = workspace;\n }\n }\n\n /**\n * Adds one or more new dependencies.\n *\n * @param newWorkspaceDependencies The dependencies to add.\n * @returns The new length of the collection.\n */\n override push(...newWorkspaceDependencies: WorkspaceDependency[]): number {\n for (let newWorkspaceDependency of newWorkspaceDependencies) {\n let doesExist = false;\n\n for (let workspaceDependency of this) {\n if (workspaceDependency.name === newWorkspaceDependency.name) {\n doesExist = true;\n\n workspaceDependency.versions = _.union(\n workspaceDependency.versions,\n newWorkspaceDependency.versions,\n );\n workspaceDependency.exactVersions = _.union(\n workspaceDependency.exactVersions,\n newWorkspaceDependency.exactVersions,\n );\n workspaceDependency.projects = _.unionWith(\n workspaceDependency.projects,\n newWorkspaceDependency.projects,\n (a, b) => a.name === b.name,\n );\n\n workspaceDependency.versions.sort(compareSemver);\n workspaceDependency.exactVersions.sort(compareSemver);\n workspaceDependency.projects.sort(compareWorkspaceDependencyProjectName);\n }\n }\n\n if (!doesExist) {\n super.push(newWorkspaceDependency);\n }\n }\n\n return this.length;\n }\n\n /**\n * Creates new {@link WorkspaceDependencies} instance from a {@link Workspace} instance and its dependencies.\n *\n * @param workspace The workspace from which the dependnecies are taken.\n * @param options Options.\n * @returns The new {@link WorkspaceDependencies} instance.\n */\n static fromWorkspace<M extends boolean = true>(\n workspace: Workspace<M>,\n options?: WorkspaceDependenciesFromWorkspaceOptions,\n ) {\n let workspaceDependencies: WorkspaceDependency[] = [];\n\n if (options?.includeWorkspaceDependencies) {\n for (let [dependencyName, dependencyVersion] of Object.entries({\n ...workspace.packageJson?.dependencies,\n ...workspace.packageJson?.devDependencies,\n })) {\n let exactDependencyVersion =\n semver.validRange(dependencyVersion) ?\n (semver.minVersion(dependencyVersion)?.format() ??\n semver.coerce(dependencyVersion)?.format() ??\n dependencyVersion.trim())\n : dependencyVersion.trim();\n\n let workspaceDependency: WorkspaceDependency = {\n name: dependencyName,\n versions: [dependencyVersion],\n exactVersions: [exactDependencyVersion],\n projects: [],\n };\n\n workspaceDependencies.push(workspaceDependency);\n }\n }\n\n for (let project of workspace.projects) {\n if (!options?.includeOnlyDevDependencies) {\n for (let [dependencyName, dependencyVersion] of Object.entries(\n project.packageJson.dependencies ?? {},\n )) {\n let exactDependencyVersion =\n semver.validRange(dependencyVersion) ?\n (semver.minVersion(dependencyVersion)?.format() ??\n semver.coerce(dependencyVersion)?.format() ??\n dependencyVersion.trim())\n : dependencyVersion.trim();\n\n let workspaceDependency: WorkspaceDependency = {\n name: dependencyName,\n versions: [dependencyVersion],\n exactVersions: [exactDependencyVersion],\n projects: [],\n };\n\n if (project.name) {\n workspaceDependency.projects = [\n {\n name: project.name,\n version: dependencyVersion,\n exactVersion: exactDependencyVersion,\n },\n ];\n }\n\n workspaceDependencies.push(workspaceDependency);\n }\n }\n\n if (options?.includeDevDependencies || options?.includeOnlyDevDependencies) {\n for (let [dependencyName, dependencyVersion] of Object.entries(\n project.packageJson.devDependencies ?? {},\n )) {\n let exactDependencyVersion =\n semver.validRange(dependencyVersion) ?\n (semver.minVersion(dependencyVersion)?.format() ??\n semver.coerce(dependencyVersion)?.format() ??\n dependencyVersion.trim())\n : dependencyVersion.trim();\n\n let workspaceDependency: WorkspaceDependency = {\n name: dependencyName,\n versions: [dependencyVersion],\n exactVersions: [exactDependencyVersion],\n projects: [],\n };\n\n if (project.name) {\n workspaceDependency.projects = [\n {\n name: project.name,\n version: dependencyVersion,\n exactVersion: exactDependencyVersion,\n },\n ];\n }\n\n workspaceDependencies.push(workspaceDependency);\n }\n }\n }\n\n return new this(...workspaceDependencies, workspace);\n }\n\n /**\n * Creates map of all dependnecies and their installed version.\n *\n * @param options Options.\n * @returns Object whose keys are dependency names and values are sorted versions.\n */\n getVersions(options?: WorkspaceDependenciesGetVersionsOptions) {\n let versions: Record<string, string[]> = {};\n\n for (let dependency of this) {\n versions[dependency.name] =\n options?.useExactVersions ? dependency.exactVersions : dependency.versions;\n }\n\n return versions;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,OAAO;AACd,OAAO,YAAY;AAEnB,SAAQ,eAAe,6CAA4C;AAS5D,aAAM,8BAAwD,MAA2B;AAAA;AAAA,EAE9F;AAAA,EAEA,eAAe,MAAgD;AAC7D,UAAM;AAEN,QAAI,KAAK,WAAW,GAAG;AACrB,OAAC,KAAK,SAAS,IAAI;AAAA,IACrB,OAAO;AACL,UAAI,SAAS,KAAK,MAAM,GAAG,EAAE;AAC7B,UAAI,YAAY,KAAK,GAAG,EAAE;AAE1B,WAAK,KAAK,GAAG,MAAM;AAEnB,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQS,QAAQ,0BAAyD;AACxE,aAAS,0BAA0B,0BAA0B;AAC3D,UAAI,YAAY;AAEhB,eAAS,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AAA,UACF;AAEA,gCAAsB,KAAK,mBAAmB;AAAA,QAChD;AAAA,MACF;AAAA,IACF;AAEA,WAAO,IAAI,KAAK,GAAG,uBAAuB,SAAS;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,YAAY,SAAmD;AAC7D,QAAI,WAAqC,CAAC;AAE1C,aAAS,cAAc,MAAM;AAC3B,eAAS,WAAW,IAAI,IACtB,SAAS,mBAAmB,WAAW,gBAAgB,WAAW;AAAA,IACtE;AAEA,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../source/workspace/internals/getRepositoryBranches.ts"],
|
|
4
|
-
"sourcesContent": ["import {simpleGit} from 'simple-git';\n\nconst REMOTE_NAME_PREFIX_REGEXP = /^[^/]*\\//iu;\n\nexport async function getRepositoryBranches(repositoryPath: string): Promise<string[] | undefined> {\n let repositoryBranches: string[] | undefined;\n\n try {\n let git = simpleGit({\n baseDir: repositoryPath,\n binary: 'git',\n maxConcurrentProcesses: 1,\n });\n\n let branchSummary = await git.branch(['-r']);\n\n repositoryBranches = branchSummary.all.map((branch) =>\n branch.replace(REMOTE_NAME_PREFIX_REGEXP, ''),\n );\n\n if (!repositoryBranches.length) {\n branchSummary = await git.branch(['-a']);\n\n repositoryBranches = branchSummary.all.map((branch) =>\n branch.replace(REMOTE_NAME_PREFIX_REGEXP, ''),\n );\n }\n } catch
|
|
5
|
-
"mappings": ";AAAA,SAAQ,iBAAgB;AAExB,MAAM,4BAA4B;AAElC,sBAAsB,sBAAsB,gBAAuD;AACjG,MAAI;AAEJ,MAAI;AACF,QAAI,MAAM,UAAU;AAAA,MAClB,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,wBAAwB;AAAA,IAC1B,CAAC;AAED,QAAI,gBAAgB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;AAE3C,yBAAqB,cAAc,IAAI;AAAA,MAAI,CAAC,WAC1C,OAAO,QAAQ,2BAA2B,EAAE;AAAA,IAC9C;AAEA,QAAI,CAAC,mBAAmB,QAAQ;AAC9B,sBAAgB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;AAEvC,2BAAqB,cAAc,IAAI;AAAA,QAAI,CAAC,WAC1C,OAAO,QAAQ,2BAA2B,EAAE;AAAA,MAC9C;AAAA,IACF;AAAA,EACF,
|
|
4
|
+
"sourcesContent": ["import {simpleGit} from 'simple-git';\n\nconst REMOTE_NAME_PREFIX_REGEXP = /^[^/]*\\//iu;\n\nexport async function getRepositoryBranches(repositoryPath: string): Promise<string[] | undefined> {\n let repositoryBranches: string[] | undefined;\n\n try {\n let git = simpleGit({\n baseDir: repositoryPath,\n binary: 'git',\n maxConcurrentProcesses: 1,\n });\n\n let branchSummary = await git.branch(['-r']);\n\n repositoryBranches = branchSummary.all.map((branch) =>\n branch.replace(REMOTE_NAME_PREFIX_REGEXP, ''),\n );\n\n if (!repositoryBranches.length) {\n branchSummary = await git.branch(['-a']);\n\n repositoryBranches = branchSummary.all.map((branch) =>\n branch.replace(REMOTE_NAME_PREFIX_REGEXP, ''),\n );\n }\n } catch {\n // no-op\n }\n\n return repositoryBranches;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAQ,iBAAgB;AAExB,MAAM,4BAA4B;AAElC,sBAAsB,sBAAsB,gBAAuD;AACjG,MAAI;AAEJ,MAAI;AACF,QAAI,MAAM,UAAU;AAAA,MAClB,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,wBAAwB;AAAA,IAC1B,CAAC;AAED,QAAI,gBAAgB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;AAE3C,yBAAqB,cAAc,IAAI;AAAA,MAAI,CAAC,WAC1C,OAAO,QAAQ,2BAA2B,EAAE;AAAA,IAC9C;AAEA,QAAI,CAAC,mBAAmB,QAAQ;AAC9B,sBAAgB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;AAEvC,2BAAqB,cAAc,IAAI;AAAA,QAAI,CAAC,WAC1C,OAAO,QAAQ,2BAA2B,EAAE;AAAA,MAC9C;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jakubmazanec/carson",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2-unstable.91147a2",
|
|
4
4
|
"description": "Tool for managing workspace and project configuration.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"typecheck": "tsc --project tsconfig.typecheck.json"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@jakubmazanec/args": "
|
|
36
|
-
"@jakubmazanec/cli": "
|
|
37
|
-
"@jakubmazanec/error": "
|
|
38
|
-
"@jakubmazanec/fs-utils": "
|
|
39
|
-
"@jakubmazanec/template": "
|
|
40
|
-
"@jakubmazanec/ts-utils": "
|
|
41
|
-
"@jakubmazanec/zod-utils": "
|
|
35
|
+
"@jakubmazanec/args": "2.0.5-unstable.91147a2",
|
|
36
|
+
"@jakubmazanec/cli": "0.3.5-unstable.91147a2",
|
|
37
|
+
"@jakubmazanec/error": "3.0.5-unstable.91147a2",
|
|
38
|
+
"@jakubmazanec/fs-utils": "0.2.5-unstable.91147a2",
|
|
39
|
+
"@jakubmazanec/template": "2.0.5-unstable.91147a2",
|
|
40
|
+
"@jakubmazanec/ts-utils": "3.0.5-unstable.91147a2",
|
|
41
|
+
"@jakubmazanec/zod-utils": "2.0.5-unstable.91147a2",
|
|
42
42
|
"chalk": "^5.3.0",
|
|
43
43
|
"fast-glob": "^3.3.2",
|
|
44
44
|
"fflate": "^0.8.2",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"zod": "^3.23.8"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@jakubmazanec/eslint-config": "
|
|
58
|
+
"@jakubmazanec/eslint-config": "4.0.0-unstable.91147a2",
|
|
59
59
|
"@types/fs-extra": "^11.0.4",
|
|
60
60
|
"@types/lodash": "^4.17.13",
|
|
61
61
|
"@types/micromatch": "^4.0.9",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"concurrently": "^9.1.0",
|
|
68
68
|
"del-cli": "^6.0.0",
|
|
69
69
|
"esbuild": "^0.24.0",
|
|
70
|
-
"eslint": "^
|
|
70
|
+
"eslint": "^9.14.0",
|
|
71
71
|
"ink": "^5.0.1",
|
|
72
72
|
"lodash": "^4.17.21",
|
|
73
73
|
"prettier": "^3.3.3",
|
|
@@ -19,7 +19,7 @@ export type CreateProjectProps = {
|
|
|
19
19
|
|
|
20
20
|
export function CreateProject({args, workspace}: CreateProjectProps) {
|
|
21
21
|
let [status, setStatus] = useState<CommandStatus>('not-started');
|
|
22
|
-
let [subscription, setSubscription] = useState<ZenObservable.Subscription
|
|
22
|
+
let [subscription, setSubscription] = useState<null | ZenObservable.Subscription>(null);
|
|
23
23
|
let [jobs, setJobs] = useState<string[]>([]);
|
|
24
24
|
let [createProjectInputResult, setCreateProjectInputResult] = useState<CreateProjectInputResult>(
|
|
25
25
|
() => ({
|
|
@@ -121,15 +121,15 @@ export function CreateProject({args, workspace}: CreateProjectProps) {
|
|
|
121
121
|
choices: possiblePaths,
|
|
122
122
|
},
|
|
123
123
|
}}
|
|
124
|
-
values={createProjectInputResult}
|
|
125
124
|
marginTop={1}
|
|
125
|
+
values={createProjectInputResult}
|
|
126
126
|
onChange={setCreateProjectInputResult}
|
|
127
127
|
onComplete={setCreateProjectInputResult}
|
|
128
128
|
/>
|
|
129
129
|
|
|
130
130
|
{status === 'in-progress' || status === 'finished' ?
|
|
131
|
-
<Box marginTop={1}
|
|
132
|
-
<Header showSpinner={status === 'in-progress'}
|
|
131
|
+
<Box flexDirection="column" marginTop={1}>
|
|
132
|
+
<Header icon={icons.success} marginBottom={1} showSpinner={status === 'in-progress'}>
|
|
133
133
|
<Text>Creating project...</Text>
|
|
134
134
|
</Header>
|
|
135
135
|
|
|
@@ -140,7 +140,7 @@ export function CreateProject({args, workspace}: CreateProjectProps) {
|
|
|
140
140
|
: null}
|
|
141
141
|
|
|
142
142
|
{status === 'finished' ?
|
|
143
|
-
<Header
|
|
143
|
+
<Header icon={icons.success} marginTop={1}>
|
|
144
144
|
<Text>Done.</Text>
|
|
145
145
|
</Header>
|
|
146
146
|
: null}
|
|
@@ -15,7 +15,7 @@ export type CreateWorkspaceProps = {
|
|
|
15
15
|
|
|
16
16
|
export function CreateWorkspace({args}: CreateWorkspaceProps) {
|
|
17
17
|
let [status, setStatus] = useState<CommandStatus>('not-started');
|
|
18
|
-
let [subscription, setSubscription] = useState<ZenObservable.Subscription
|
|
18
|
+
let [subscription, setSubscription] = useState<null | ZenObservable.Subscription>(null);
|
|
19
19
|
let [jobs, setJobs] = useState<string[]>([]);
|
|
20
20
|
let [createWorkspaceInputResult, setCreateWorkspaceInputResult] =
|
|
21
21
|
useState<CreateWorkspaceInputResult>(() => ({
|
|
@@ -64,15 +64,15 @@ export function CreateWorkspace({args}: CreateWorkspaceProps) {
|
|
|
64
64
|
<Text>{`Creating workspace at ${chalk[colors.info](workspacePath)}.`}</Text>
|
|
65
65
|
|
|
66
66
|
<CreateWorkspaceInput
|
|
67
|
-
values={createWorkspaceInputResult}
|
|
68
67
|
marginTop={1}
|
|
68
|
+
values={createWorkspaceInputResult}
|
|
69
69
|
onChange={setCreateWorkspaceInputResult}
|
|
70
70
|
onComplete={setCreateWorkspaceInputResult}
|
|
71
71
|
/>
|
|
72
72
|
|
|
73
73
|
{status === 'in-progress' || status === 'finished' ?
|
|
74
|
-
<Box marginTop={1}
|
|
75
|
-
<Header showSpinner={status === 'in-progress'}
|
|
74
|
+
<Box flexDirection="column" marginTop={1}>
|
|
75
|
+
<Header icon={icons.success} marginBottom={1} showSpinner={status === 'in-progress'}>
|
|
76
76
|
<Text>Creating workspace...</Text>
|
|
77
77
|
</Header>
|
|
78
78
|
|
|
@@ -83,7 +83,7 @@ export function CreateWorkspace({args}: CreateWorkspaceProps) {
|
|
|
83
83
|
: null}
|
|
84
84
|
|
|
85
85
|
{status === 'finished' ?
|
|
86
|
-
<Header
|
|
86
|
+
<Header icon={icons.success} marginTop={1}>
|
|
87
87
|
<Text>Done.</Text>
|
|
88
88
|
</Header>
|
|
89
89
|
: null}
|
|
@@ -39,8 +39,8 @@ export function UpdateWorkspace({workspace, args}: UpdateWorkspaceProps) {
|
|
|
39
39
|
<Box flexDirection="column">
|
|
40
40
|
<Text>{`Updating workspace at ${chalk[colors.info](workspace.path)}.`}</Text>
|
|
41
41
|
|
|
42
|
-
<Box marginTop={1}
|
|
43
|
-
<Header
|
|
42
|
+
<Box flexDirection="column" marginTop={1}>
|
|
43
|
+
<Header icon={icons.success} marginBottom={1} showSpinner={!isFinished}>
|
|
44
44
|
<Text>Updating workspace and projects...</Text>
|
|
45
45
|
</Header>
|
|
46
46
|
|
|
@@ -50,7 +50,7 @@ export function UpdateWorkspace({workspace, args}: UpdateWorkspaceProps) {
|
|
|
50
50
|
</Box>
|
|
51
51
|
|
|
52
52
|
{isFinished ?
|
|
53
|
-
<Header
|
|
53
|
+
<Header icon={icons.success} marginTop={1}>
|
|
54
54
|
<Text>Done.</Text>
|
|
55
55
|
</Header>
|
|
56
56
|
: null}
|
|
@@ -20,7 +20,7 @@ export const updateWorkspaceCommand = new Command(
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
await program.renderElement(<UpdateWorkspace
|
|
23
|
+
await program.renderElement(<UpdateWorkspace args={args} workspace={workspace} />);
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
description: 'Updates files in a workspace.',
|
|
@@ -6,11 +6,8 @@ import {type templateDataSchema} from './TemplateData.js';
|
|
|
6
6
|
/**
|
|
7
7
|
* A result of rendering a Carson template file.
|
|
8
8
|
*/
|
|
9
|
-
export type TemplateRender =
|
|
10
|
-
typeof templateAttributesSchema,
|
|
11
|
-
typeof templateDataSchema
|
|
12
|
-
> & {
|
|
9
|
+
export type TemplateRender = {
|
|
13
10
|
template: {
|
|
14
11
|
path: string;
|
|
15
12
|
};
|
|
16
|
-
}
|
|
13
|
+
} & BaseTemplateRender<typeof templateAttributesSchema, typeof templateDataSchema>;
|
|
@@ -395,21 +395,21 @@ export class Workspace<M extends boolean = true> {
|
|
|
395
395
|
/**
|
|
396
396
|
* Traverses file system up from the search path and tries to find and read a workspace.
|
|
397
397
|
*/
|
|
398
|
-
static async findAndRead<O extends
|
|
398
|
+
static async findAndRead<O extends undefined | WorkspaceFindAndReadOptions = undefined>(
|
|
399
399
|
searchPath: string,
|
|
400
400
|
options?: O,
|
|
401
401
|
): Promise<
|
|
402
|
-
O extends undefined ? Workspace | Workspace<false>
|
|
402
|
+
O extends undefined ? undefined | Workspace | Workspace<false>
|
|
403
403
|
: NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>
|
|
404
|
-
: Workspace | Workspace<false>
|
|
404
|
+
: undefined | Workspace | Workspace<false>
|
|
405
405
|
> {
|
|
406
406
|
let workspacePath = await Workspace.find(searchPath);
|
|
407
407
|
|
|
408
408
|
if (workspacePath) {
|
|
409
409
|
return Workspace.read(workspacePath) as Promise<
|
|
410
|
-
O extends undefined ? Workspace | Workspace<false>
|
|
410
|
+
O extends undefined ? undefined | Workspace | Workspace<false>
|
|
411
411
|
: NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>
|
|
412
|
-
: Workspace | Workspace<false>
|
|
412
|
+
: undefined | Workspace | Workspace<false>
|
|
413
413
|
>;
|
|
414
414
|
} else if (options?.throwIfNotFound) {
|
|
415
415
|
throw new WorkspaceError('NO_WORKSPACE_FOUND', {
|
|
@@ -421,9 +421,9 @@ export class Workspace<M extends boolean = true> {
|
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
return undefined as unknown as Promise<
|
|
424
|
-
O extends undefined ? Workspace | Workspace<false>
|
|
424
|
+
O extends undefined ? undefined | Workspace | Workspace<false>
|
|
425
425
|
: NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>
|
|
426
|
-
: Workspace | Workspace<false>
|
|
426
|
+
: undefined | Workspace | Workspace<false>
|
|
427
427
|
>;
|
|
428
428
|
}
|
|
429
429
|
|