@jakubmazanec/carson 1.2.2-unstable.91147a2 → 1.2.2-unstable.9aff2d1

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.
@@ -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<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"],
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 | null>(null);\n let [jobs, setJobs] = useState<string[]>([]);\n let [createProjectInputResult, setCreateProjectInputResult] = useState<CreateProjectInputResult>(\n () => ({\n projectName: {value: args.options.name ?? '', isComplete: !!args.options.name},\n projectPath: {value: '', isComplete: false},\n templateId: {value: args.options.template ?? '', isComplete: !!args.options.template},\n }),\n );\n let {exit} = useProgram();\n\n useEffect(() => {\n if (Object.entries(createProjectInputResult).every(([, result]) => result.isComplete)) {\n setStatus('in-progress');\n }\n }, [createProjectInputResult]);\n\n useEffect(() => {\n if (status === 'in-progress' && !subscription) {\n let newSubscription = runCreateProject({\n projectPath: createProjectInputResult.projectPath.value,\n templateId: createProjectInputResult.templateId.value,\n projectName: createProjectInputResult.projectName.value,\n workspace,\n args,\n }).subscribe({\n next(value) {\n setJobs((previousJobs) => [...previousJobs, value]);\n },\n error(error) {\n exit(error);\n },\n complete() {\n newSubscription.unsubscribe();\n setStatus('finished');\n },\n });\n setSubscription(newSubscription);\n }\n\n return () => {\n if (subscription) {\n subscription.unsubscribe();\n }\n };\n }, [args, createProjectInputResult, exit, status, subscription, workspace]);\n\n let possiblePaths: Array<{value: string; label: string}> = [];\n\n if (createProjectInputResult.projectName.value) {\n let destinationDirectory = packageNameToDirectory(createProjectInputResult.projectName.value);\n\n if (workspace.projectGlobs) {\n possiblePaths = workspace.projectGlobs\n .filter((projectGlob) => ONLY_ONE_STAR_REGEXP.test(projectGlob))\n .map((projectGlob) => projectGlob.replace(/\\*/, destinationDirectory))\n .map((projectGlob) => path.join(workspace.path, projectGlob))\n .map((projectPath) => ({\n value: projectPath,\n label: path.relative(workspace.path, projectPath).replace('\\\\', '/'),\n }));\n\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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AO;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,WAAW;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-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<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"],
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 | null>(null);\n let [jobs, setJobs] = useState<string[]>([]);\n let [createWorkspaceInputResult, setCreateWorkspaceInputResult] =\n useState<CreateWorkspaceInputResult>(() => ({\n templateId: {value: args.options.template ?? '', isComplete: !!args.options.template},\n }));\n let {exit} = useProgram();\n let workspacePath = path.resolve(process.cwd(), args.options.path ?? '');\n\n useEffect(() => {\n if (Object.entries(createWorkspaceInputResult).every(([, result]) => result.isComplete)) {\n setStatus('in-progress');\n }\n }, [createWorkspaceInputResult]);\n\n useEffect(() => {\n if (status === 'in-progress' && !subscription) {\n let newSubscription = runCreateWorkspace({\n workspacePath,\n templateId: createWorkspaceInputResult.templateId.value,\n args,\n }).subscribe({\n next(value) {\n setJobs((previousJobs) => [...previousJobs, value]);\n },\n error(error) {\n exit(error);\n },\n complete() {\n newSubscription.unsubscribe();\n setStatus('finished');\n },\n });\n\n setSubscription(newSubscription);\n }\n\n return () => {\n if (subscription) {\n subscription.unsubscribe();\n }\n };\n }, [createWorkspaceInputResult, status, subscription, args, exit, workspacePath]);\n\n return (\n <Box flexDirection=\"column\">\n <Text>{`Creating workspace at ${chalk[colors.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
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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AAC,QAAK,mCAAqB,GAC7B;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,2 +1,2 @@
1
- export * from './internals/CommandStatus.js';
1
+ export type * from './internals/CommandStatus.js';
2
2
  export * from './internals/packageNameToDirectory.js';
@@ -1,4 +1,3 @@
1
1
  "use strict";
2
- export * from "./internals/CommandStatus.js";
3
2
  export * from "./internals/packageNameToDirectory.js";
4
3
  //# sourceMappingURL=internals.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../source/commands/internals.ts"],
4
- "sourcesContent": ["export * from './internals/CommandStatus.js';\nexport * from './internals/packageNameToDirectory.js';\n"],
5
- "mappings": ";AAAA,cAAc;AACd,cAAc;",
4
+ "sourcesContent": ["export type * from './internals/CommandStatus.js';\nexport * from './internals/packageNameToDirectory.js';\n"],
5
+ "mappings": ";AACA,cAAc;",
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 = BaseTemplateRender<typeof templateAttributesSchema, typeof templateDataSchema> & {
8
8
  template: {
9
9
  path: string;
10
10
  };
11
- } & BaseTemplateRender<typeof templateAttributesSchema, typeof templateDataSchema>;
11
+ };
@@ -1,9 +1,9 @@
1
1
  export * from './template/applyTemplateRenders.js';
2
- export * from './template/CarsonTemplate.js';
2
+ export type * from './template/CarsonTemplate.js';
3
3
  export * from './template/CarsonTemplateConfig.js';
4
4
  export * from './template/CarsonTemplateError.js';
5
5
  export * from './template/renderCarsonTemplate.js';
6
6
  export * from './template/TemplateAttributes.js';
7
7
  export * from './template/TemplateData.js';
8
- export * from './template/TemplateRender.js';
9
- export * from './template/TemplateRenders.js';
8
+ export type * from './template/TemplateRender.js';
9
+ export type * from './template/TemplateRenders.js';
package/build/template.js CHANGED
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
2
  export * from "./template/applyTemplateRenders.js";
3
- export * from "./template/CarsonTemplate.js";
4
3
  export * from "./template/CarsonTemplateConfig.js";
5
4
  export * from "./template/CarsonTemplateError.js";
6
5
  export * from "./template/renderCarsonTemplate.js";
7
6
  export * from "./template/TemplateAttributes.js";
8
7
  export * from "./template/TemplateData.js";
9
- export * from "./template/TemplateRender.js";
10
- export * from "./template/TemplateRenders.js";
11
8
  //# sourceMappingURL=template.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../source/template.ts"],
4
- "sourcesContent": ["export * from './template/applyTemplateRenders.js';\nexport * from './template/CarsonTemplate.js';\nexport * from './template/CarsonTemplateConfig.js';\nexport * from './template/CarsonTemplateError.js';\nexport * from './template/renderCarsonTemplate.js';\nexport * from './template/TemplateAttributes.js';\nexport * from './template/TemplateData.js';\nexport * from './template/TemplateRender.js';\nexport * from './template/TemplateRenders.js';\n"],
5
- "mappings": ";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
4
+ "sourcesContent": ["export * from './template/applyTemplateRenders.js';\nexport type * from './template/CarsonTemplate.js';\nexport * from './template/CarsonTemplateConfig.js';\nexport * from './template/CarsonTemplateError.js';\nexport * from './template/renderCarsonTemplate.js';\nexport * from './template/TemplateAttributes.js';\nexport * from './template/TemplateData.js';\nexport type * from './template/TemplateRender.js';\nexport type * from './template/TemplateRenders.js';\n"],
5
+ "mappings": ";AAAA,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
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 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>>;
63
+ static findAndRead<O extends WorkspaceFindAndReadOptions | undefined = undefined>(searchPath: string, options?: O): Promise<O extends undefined ? Workspace | Workspace<false> | undefined : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false> : Workspace | Workspace<false> | undefined>;
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 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"],
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"],
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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M;AAAA,MAC/D,4BAA4B;AAAA,IAC9B,CAAC;AACD,SAAK,kBAAkB,sBAAsB,cAAc,MAAM;AAAA,MAC/D,wBAAwB;AAAA,MACxB,8BAA8B;AAAA,IAChC,CAAC;AACD,SAAK,qBAAqB,KAAK,gBAAgB,YAAY;AAAA,MACzD,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACF;",
6
6
  "names": ["projectGlobs", "workspace"]
7
7
  }
@@ -1,22 +1,22 @@
1
1
  export * from './workspace/Project.js';
2
2
  export * from './workspace/ProjectConfig.js';
3
- export * from './workspace/ProjectCreateOptions.js';
3
+ export type * from './workspace/ProjectCreateOptions.js';
4
4
  export * from './workspace/ProjectError.js';
5
- export * from './workspace/ProjectOptions.js';
6
- export * from './workspace/ProjectUpdateOptions.js';
5
+ export type * from './workspace/ProjectOptions.js';
6
+ export type * from './workspace/ProjectUpdateOptions.js';
7
7
  export * from './workspace/saveProjectConfig.js';
8
8
  export * from './workspace/saveWorkspaceConfig.js';
9
9
  export * from './workspace/Workspace.js';
10
10
  export * from './workspace/WorkspaceConfig.js';
11
- export * from './workspace/WorkspaceCreateOptions.js';
12
- export * from './workspace/WorkspaceCreateProjectOptions.js';
11
+ export type * from './workspace/WorkspaceCreateOptions.js';
12
+ export type * from './workspace/WorkspaceCreateProjectOptions.js';
13
13
  export * from './workspace/WorkspaceDependencies.js';
14
14
  export * from './workspace/WorkspaceError.js';
15
- export * from './workspace/WorkspaceFindAndReadOptions.js';
16
- export * from './workspace/WorkspaceOptions.js';
17
- export * from './workspace/WorkspaceOptionsProject.js';
18
- export * from './workspace/WorkspacePackageJson.js';
19
- export * from './workspace/WorkspaceProjectGlobs.js';
20
- export * from './workspace/WorkspaceProjects.js';
21
- export * from './workspace/WorkspaceRepository.js';
22
- export * from './workspace/WorkspaceUpdateOptions.js';
15
+ export type * from './workspace/WorkspaceFindAndReadOptions.js';
16
+ export type * from './workspace/WorkspaceOptions.js';
17
+ export type * from './workspace/WorkspaceOptionsProject.js';
18
+ export type * from './workspace/WorkspacePackageJson.js';
19
+ export type * from './workspace/WorkspaceProjectGlobs.js';
20
+ export type * from './workspace/WorkspaceProjects.js';
21
+ export type * from './workspace/WorkspaceRepository.js';
22
+ export type * from './workspace/WorkspaceUpdateOptions.js';
@@ -1,24 +1,11 @@
1
1
  "use strict";
2
2
  export * from "./workspace/Project.js";
3
3
  export * from "./workspace/ProjectConfig.js";
4
- export * from "./workspace/ProjectCreateOptions.js";
5
4
  export * from "./workspace/ProjectError.js";
6
- export * from "./workspace/ProjectOptions.js";
7
- export * from "./workspace/ProjectUpdateOptions.js";
8
5
  export * from "./workspace/saveProjectConfig.js";
9
6
  export * from "./workspace/saveWorkspaceConfig.js";
10
7
  export * from "./workspace/Workspace.js";
11
8
  export * from "./workspace/WorkspaceConfig.js";
12
- export * from "./workspace/WorkspaceCreateOptions.js";
13
- export * from "./workspace/WorkspaceCreateProjectOptions.js";
14
9
  export * from "./workspace/WorkspaceDependencies.js";
15
10
  export * from "./workspace/WorkspaceError.js";
16
- export * from "./workspace/WorkspaceFindAndReadOptions.js";
17
- export * from "./workspace/WorkspaceOptions.js";
18
- export * from "./workspace/WorkspaceOptionsProject.js";
19
- export * from "./workspace/WorkspacePackageJson.js";
20
- export * from "./workspace/WorkspaceProjectGlobs.js";
21
- export * from "./workspace/WorkspaceProjects.js";
22
- export * from "./workspace/WorkspaceRepository.js";
23
- export * from "./workspace/WorkspaceUpdateOptions.js";
24
11
  //# sourceMappingURL=workspace.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../source/workspace.ts"],
4
- "sourcesContent": ["export * from './workspace/Project.js';\nexport * from './workspace/ProjectConfig.js';\nexport * from './workspace/ProjectCreateOptions.js';\nexport * from './workspace/ProjectError.js';\nexport * from './workspace/ProjectOptions.js';\nexport * from './workspace/ProjectUpdateOptions.js';\nexport * from './workspace/saveProjectConfig.js';\nexport * from './workspace/saveWorkspaceConfig.js';\nexport * from './workspace/Workspace.js';\nexport * from './workspace/WorkspaceConfig.js';\nexport * from './workspace/WorkspaceCreateOptions.js';\nexport * from './workspace/WorkspaceCreateProjectOptions.js';\nexport * from './workspace/WorkspaceDependencies.js';\nexport * from './workspace/WorkspaceError.js';\nexport * from './workspace/WorkspaceFindAndReadOptions.js';\nexport * from './workspace/WorkspaceOptions.js';\nexport * from './workspace/WorkspaceOptionsProject.js';\nexport * from './workspace/WorkspacePackageJson.js';\nexport * from './workspace/WorkspaceProjectGlobs.js';\nexport * from './workspace/WorkspaceProjects.js';\nexport * from './workspace/WorkspaceRepository.js';\nexport * from './workspace/WorkspaceUpdateOptions.js';\n"],
5
- "mappings": ";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
4
+ "sourcesContent": ["export * from './workspace/Project.js';\nexport * from './workspace/ProjectConfig.js';\nexport type * from './workspace/ProjectCreateOptions.js';\nexport * from './workspace/ProjectError.js';\nexport type * from './workspace/ProjectOptions.js';\nexport type * from './workspace/ProjectUpdateOptions.js';\nexport * from './workspace/saveProjectConfig.js';\nexport * from './workspace/saveWorkspaceConfig.js';\nexport * from './workspace/Workspace.js';\nexport * from './workspace/WorkspaceConfig.js';\nexport type * from './workspace/WorkspaceCreateOptions.js';\nexport type * from './workspace/WorkspaceCreateProjectOptions.js';\nexport * from './workspace/WorkspaceDependencies.js';\nexport * from './workspace/WorkspaceError.js';\nexport type * from './workspace/WorkspaceFindAndReadOptions.js';\nexport type * from './workspace/WorkspaceOptions.js';\nexport type * from './workspace/WorkspaceOptionsProject.js';\nexport type * from './workspace/WorkspacePackageJson.js';\nexport type * from './workspace/WorkspaceProjectGlobs.js';\nexport type * from './workspace/WorkspaceProjects.js';\nexport type * from './workspace/WorkspaceRepository.js';\nexport type * from './workspace/WorkspaceUpdateOptions.js';\n"],
5
+ "mappings": ";AAAA,cAAc;AACd,cAAc;AAEd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jakubmazanec/carson",
3
- "version": "1.2.2-unstable.91147a2",
3
+ "version": "1.2.2-unstable.9aff2d1",
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": "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",
35
+ "@jakubmazanec/args": "2.0.5-unstable.9aff2d1",
36
+ "@jakubmazanec/cli": "0.3.5-unstable.9aff2d1",
37
+ "@jakubmazanec/error": "3.0.5-unstable.9aff2d1",
38
+ "@jakubmazanec/fs-utils": "0.2.5-unstable.9aff2d1",
39
+ "@jakubmazanec/template": "2.0.5-unstable.9aff2d1",
40
+ "@jakubmazanec/ts-utils": "3.0.5-unstable.9aff2d1",
41
+ "@jakubmazanec/zod-utils": "2.0.5-unstable.9aff2d1",
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": "4.0.0-unstable.91147a2",
58
+ "@jakubmazanec/eslint-config": "4.0.0-unstable.9aff2d1",
59
59
  "@types/fs-extra": "^11.0.4",
60
60
  "@types/lodash": "^4.17.13",
61
61
  "@types/micromatch": "^4.0.9",
@@ -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<null | ZenObservable.Subscription>(null);
22
+ let [subscription, setSubscription] = useState<ZenObservable.Subscription | null>(null);
23
23
  let [jobs, setJobs] = useState<string[]>([]);
24
24
  let [createProjectInputResult, setCreateProjectInputResult] = useState<CreateProjectInputResult>(
25
25
  () => ({
@@ -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<null | ZenObservable.Subscription>(null);
18
+ let [subscription, setSubscription] = useState<ZenObservable.Subscription | null>(null);
19
19
  let [jobs, setJobs] = useState<string[]>([]);
20
20
  let [createWorkspaceInputResult, setCreateWorkspaceInputResult] =
21
21
  useState<CreateWorkspaceInputResult>(() => ({
@@ -1,2 +1,2 @@
1
- export * from './internals/CommandStatus.js';
1
+ export type * from './internals/CommandStatus.js';
2
2
  export * from './internals/packageNameToDirectory.js';
@@ -6,8 +6,11 @@ import {type templateDataSchema} from './TemplateData.js';
6
6
  /**
7
7
  * A result of rendering a Carson template file.
8
8
  */
9
- export type TemplateRender = {
9
+ export type TemplateRender = BaseTemplateRender<
10
+ typeof templateAttributesSchema,
11
+ typeof templateDataSchema
12
+ > & {
10
13
  template: {
11
14
  path: string;
12
15
  };
13
- } & BaseTemplateRender<typeof templateAttributesSchema, typeof templateDataSchema>;
16
+ };
@@ -1,9 +1,9 @@
1
1
  export * from './template/applyTemplateRenders.js';
2
- export * from './template/CarsonTemplate.js';
2
+ export type * from './template/CarsonTemplate.js';
3
3
  export * from './template/CarsonTemplateConfig.js';
4
4
  export * from './template/CarsonTemplateError.js';
5
5
  export * from './template/renderCarsonTemplate.js';
6
6
  export * from './template/TemplateAttributes.js';
7
7
  export * from './template/TemplateData.js';
8
- export * from './template/TemplateRender.js';
9
- export * from './template/TemplateRenders.js';
8
+ export type * from './template/TemplateRender.js';
9
+ export type * from './template/TemplateRenders.js';
@@ -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 undefined | WorkspaceFindAndReadOptions = undefined>(
398
+ static async findAndRead<O extends WorkspaceFindAndReadOptions | undefined = undefined>(
399
399
  searchPath: string,
400
400
  options?: O,
401
401
  ): Promise<
402
- O extends undefined ? undefined | Workspace | Workspace<false>
402
+ O extends undefined ? Workspace | Workspace<false> | undefined
403
403
  : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>
404
- : undefined | Workspace | Workspace<false>
404
+ : Workspace | Workspace<false> | undefined
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 ? undefined | Workspace | Workspace<false>
410
+ O extends undefined ? Workspace | Workspace<false> | undefined
411
411
  : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>
412
- : undefined | Workspace | Workspace<false>
412
+ : Workspace | Workspace<false> | undefined
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 ? undefined | Workspace | Workspace<false>
424
+ O extends undefined ? Workspace | Workspace<false> | undefined
425
425
  : NonNullable<O>['throwIfNotFound'] extends true ? Workspace | Workspace<false>
426
- : undefined | Workspace | Workspace<false>
426
+ : Workspace | Workspace<false> | undefined
427
427
  >;
428
428
  }
429
429
 
@@ -1,22 +1,22 @@
1
1
  export * from './workspace/Project.js';
2
2
  export * from './workspace/ProjectConfig.js';
3
- export * from './workspace/ProjectCreateOptions.js';
3
+ export type * from './workspace/ProjectCreateOptions.js';
4
4
  export * from './workspace/ProjectError.js';
5
- export * from './workspace/ProjectOptions.js';
6
- export * from './workspace/ProjectUpdateOptions.js';
5
+ export type * from './workspace/ProjectOptions.js';
6
+ export type * from './workspace/ProjectUpdateOptions.js';
7
7
  export * from './workspace/saveProjectConfig.js';
8
8
  export * from './workspace/saveWorkspaceConfig.js';
9
9
  export * from './workspace/Workspace.js';
10
10
  export * from './workspace/WorkspaceConfig.js';
11
- export * from './workspace/WorkspaceCreateOptions.js';
12
- export * from './workspace/WorkspaceCreateProjectOptions.js';
11
+ export type * from './workspace/WorkspaceCreateOptions.js';
12
+ export type * from './workspace/WorkspaceCreateProjectOptions.js';
13
13
  export * from './workspace/WorkspaceDependencies.js';
14
14
  export * from './workspace/WorkspaceError.js';
15
- export * from './workspace/WorkspaceFindAndReadOptions.js';
16
- export * from './workspace/WorkspaceOptions.js';
17
- export * from './workspace/WorkspaceOptionsProject.js';
18
- export * from './workspace/WorkspacePackageJson.js';
19
- export * from './workspace/WorkspaceProjectGlobs.js';
20
- export * from './workspace/WorkspaceProjects.js';
21
- export * from './workspace/WorkspaceRepository.js';
22
- export * from './workspace/WorkspaceUpdateOptions.js';
15
+ export type * from './workspace/WorkspaceFindAndReadOptions.js';
16
+ export type * from './workspace/WorkspaceOptions.js';
17
+ export type * from './workspace/WorkspaceOptionsProject.js';
18
+ export type * from './workspace/WorkspacePackageJson.js';
19
+ export type * from './workspace/WorkspaceProjectGlobs.js';
20
+ export type * from './workspace/WorkspaceProjects.js';
21
+ export type * from './workspace/WorkspaceRepository.js';
22
+ export type * from './workspace/WorkspaceUpdateOptions.js';