@uniformdev/transformer 1.1.41 → 1.1.42

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/dist/cli/index.js CHANGED
@@ -6829,7 +6829,7 @@ var GenerateMissingProjectMapNodesService = class {
6829
6829
  this.logger = logger;
6830
6830
  }
6831
6831
  async generate(options) {
6832
- const { rootDir, projectMapNodesDir, compositionsDir, rootContentTypes, whatIf, strict } = options;
6832
+ const { rootDir, projectMapNodesDir, whatIf } = options;
6833
6833
  const nodesDirFull = this.fileSystem.resolvePath(rootDir, projectMapNodesDir);
6834
6834
  const nodesDirExists = await this.fileSystem.fileExists(nodesDirFull);
6835
6835
  if (!nodesDirExists) {
@@ -6858,41 +6858,8 @@ var GenerateMissingProjectMapNodesService = class {
6858
6858
  allNodes.push({ filePath, node });
6859
6859
  }
6860
6860
  const existingPaths = new Set(allNodes.map(({ node }) => node.path));
6861
- const compositionsDirFull = this.fileSystem.resolvePath(rootDir, compositionsDir);
6862
- const compositionIdToType = /* @__PURE__ */ new Map();
6863
- const compositionsDirExists = await this.fileSystem.fileExists(compositionsDirFull);
6864
- if (!compositionsDirExists) {
6865
- this.logger.warn(`Compositions directory not found: ${compositionsDir} \u2014 no source nodes will match`);
6866
- } else {
6867
- const compositionFiles = await this.fileSystem.findFiles(
6868
- compositionsDirFull,
6869
- "**/*.{json,yaml,yml}"
6870
- );
6871
- for (const filePath of compositionFiles) {
6872
- let comp;
6873
- try {
6874
- comp = await this.fileSystem.readFile(filePath);
6875
- } catch {
6876
- this.logger.warn(`Could not read composition file: ${filePath} \u2014 skipping`);
6877
- continue;
6878
- }
6879
- if (comp?.composition?._id && comp?.composition?.type) {
6880
- compositionIdToType.set(comp.composition._id, comp.composition.type);
6881
- }
6882
- }
6883
- }
6884
- const sourceNodes = allNodes.filter(({ node }) => {
6885
- if (!node.compositionId) return false;
6886
- const rootType = compositionIdToType.get(node.compositionId);
6887
- if (!rootType) {
6888
- this.logger.warn(
6889
- `No composition found for compositionId "${node.compositionId}" (node path: ${node.path}) \u2014 skipping`
6890
- );
6891
- return false;
6892
- }
6893
- return this.matchesContentType(rootType, rootContentTypes, strict);
6894
- });
6895
- this.logger.info(`${sourceNodes.length} node(s) match root content types`);
6861
+ const sourceNodes = allNodes.filter(({ node }) => !!node.compositionId);
6862
+ this.logger.info(`${sourceNodes.length} node(s) selected as sources`);
6896
6863
  const ancestorPaths = /* @__PURE__ */ new Set();
6897
6864
  for (const { node } of sourceNodes) {
6898
6865
  for (const ancestor of this.computeAncestorPaths(node.path)) {
@@ -6949,52 +6916,25 @@ var GenerateMissingProjectMapNodesService = class {
6949
6916
  const slug = nodePath.split("/").filter((s) => s.length > 0).join("-");
6950
6917
  return `${slug}-node.yaml`;
6951
6918
  }
6952
- matchesContentType(rootType, rootContentTypes, strict) {
6953
- for (const ct of rootContentTypes) {
6954
- if (strict) {
6955
- if (rootType === ct) return true;
6956
- } else {
6957
- if (rootType.toLowerCase() === ct.toLowerCase()) return true;
6958
- }
6959
- }
6960
- return false;
6961
- }
6962
6919
  };
6963
6920
 
6964
6921
  // src/cli/commands/generate-missing-project-map-nodes.ts
6965
6922
  function createGenerateMissingProjectMapNodesCommand() {
6966
6923
  const command = new Command19("generate-missing-project-map-nodes");
6967
6924
  command.description(
6968
- "Creates group project map nodes for ancestor path segments that are missing from the project map. Only paths reachable from compositions whose root type matches --rootContentTypes are considered."
6969
- ).option(
6970
- "--rootContentTypes <types>",
6971
- 'Pipe-separated list of root component types identifying the leaf-page compositions whose ancestor paths should be filled in (e.g. "BlogPost|NewsArticle")'
6972
- ).hook("preAction", (thisCommand) => {
6973
- const opts = thisCommand.opts();
6974
- const requiredOptions = [{ name: "rootContentTypes", flag: "--rootContentTypes" }];
6975
- const missing = requiredOptions.filter((opt) => !opts[opt.name]).map((opt) => opt.flag);
6976
- if (missing.length > 0) {
6977
- console.error(`error: missing required options: ${missing.join(", ")}`);
6978
- process.exit(1);
6979
- }
6980
- }).action(async (opts, cmd) => {
6925
+ "Creates group project map nodes for ancestor path segments that are missing from the project map. All project map nodes with a compositionId are used as sources."
6926
+ ).action(async (opts, cmd) => {
6981
6927
  const globalOpts = cmd.optsWithGlobals();
6982
6928
  const options = {
6983
- ...globalOpts,
6984
- rootContentTypes: opts.rootContentTypes
6929
+ ...globalOpts
6985
6930
  };
6986
6931
  const logger = new Logger();
6987
- logger.info(`rootContentTypes: ${options.rootContentTypes}`);
6988
- const rootContentTypes = splitList(options.rootContentTypes);
6989
6932
  const fileSystem = new FileSystemService();
6990
6933
  const service = new GenerateMissingProjectMapNodesService(fileSystem, logger);
6991
6934
  const result = await service.generate({
6992
6935
  rootDir: options.rootDir,
6993
6936
  projectMapNodesDir: options.projectMapNodesDir,
6994
- compositionsDir: options.compositionsDir,
6995
- rootContentTypes,
6996
- whatIf: options.whatIf ?? false,
6997
- strict: options.strict ?? false
6937
+ whatIf: options.whatIf ?? false
6998
6938
  });
6999
6939
  logger.success(
7000
6940
  `Created ${result.generatedCount} missing project map node(s). ${result.alreadyCoveredCount} ancestor path(s) already existed.`
@@ -7006,7 +6946,7 @@ function createGenerateMissingProjectMapNodesCommand() {
7006
6946
  // package.json
7007
6947
  var package_default = {
7008
6948
  name: "@uniformdev/transformer",
7009
- version: "1.1.41",
6949
+ version: "1.1.42",
7010
6950
  description: "CLI tool for transforming Uniform.dev serialization files offline",
7011
6951
  type: "module",
7012
6952
  bin: {