@cloudcannon/configuration-loader 0.0.8 → 0.0.10

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/load.js CHANGED
@@ -8,7 +8,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
8
8
  };
9
9
  import { globSync } from 'node:fs';
10
10
  import { readFile } from 'node:fs/promises';
11
- import { dirname, resolve } from 'node:path';
11
+ import { dirname, relative, resolve } from 'node:path';
12
12
  import { mergeConfiguration } from "./loader.js";
13
13
  /**
14
14
  * Attempts to load the js-yaml package dynamically.
@@ -86,11 +86,20 @@ export async function loadConfiguration(configPath, options) {
86
86
  // Glob operations are typically fast (just directory traversal), while file
87
87
  // reading (handled by loadConfigFile) is the slower I/O operation.
88
88
  findFilesMatchingGlobs: (globs) => {
89
- const resolvedGlobs = globs.map((g) => {
89
+ const resolvedGlobs = globs.flatMap((g) => {
90
90
  if (g.startsWith('!')) {
91
- return `!${resolve(configDir, g.slice(1))}`;
91
+ const pattern = g.slice(1);
92
+ const resolved = resolve(configDir, pattern.startsWith('/') ? pattern.slice(1) : pattern);
93
+ if (relative(configDir, resolved).startsWith('..')) {
94
+ return [];
95
+ }
96
+ return [`!${resolved}`];
92
97
  }
93
- return resolve(configDir, g);
98
+ const resolved = resolve(configDir, g.startsWith('/') ? g.slice(1) : g);
99
+ if (relative(configDir, resolved).startsWith('..')) {
100
+ return [];
101
+ }
102
+ return [resolved];
94
103
  });
95
104
  return globSync(resolvedGlobs);
96
105
  },
package/dist/loader.js CHANGED
@@ -49,6 +49,7 @@ class ConfigurationLoader {
49
49
  await this.importFromGlobKey(config, '_snippets_definitions_from_glob', '_snippets_definitions', false);
50
50
  await this.importFromGlobKey(config, 'collections_config_from_glob', 'collections_config', false);
51
51
  await this.importFromGlobKey(config, '_inputs_from_glob', '_inputs', false);
52
+ await this.importFromGlobKey(config, '_editables_from_glob', '_editables', false);
52
53
  await this.importFromGlobKey(config, '_structures_from_glob', '_structures', false);
53
54
  await this.processInputsKey(config._inputs);
54
55
  await this.processStructuresKey(config._structures);
@@ -63,17 +64,31 @@ class ConfigurationLoader {
63
64
  }
64
65
  const collection = config.collections_config[collectionKey];
65
66
  await this.importFromGlobKey(collection, '_inputs_from_glob', '_inputs', false);
67
+ await this.importFromGlobKey(collection, '_editables_from_glob', '_editables', false);
66
68
  await this.importFromGlobKey(collection, '_structures_from_glob', '_structures', false);
67
69
  await this.processInputsKey(collection._inputs);
68
70
  await this.processStructuresKey(collection._structures);
71
+ if (isObject(collection.create)) {
72
+ await this.importFromGlobKey(collection.create, '_inputs_from_glob', '_inputs', false);
73
+ await this.importFromGlobKey(collection.create, '_structures_from_glob', '_structures', false);
74
+ await this.processInputsKey(collection.create._inputs);
75
+ await this.processStructuresKey(collection.create._structures);
76
+ }
69
77
  // Process recursive globs in schemas
70
78
  if (isObject(collection.schemas)) {
71
79
  for (const schemaValue of Object.values(collection.schemas)) {
72
80
  if (isObject(schemaValue)) {
73
81
  await this.importFromGlobKey(schemaValue, '_inputs_from_glob', '_inputs', false);
82
+ await this.importFromGlobKey(schemaValue, '_editables_from_glob', '_editables', false);
74
83
  await this.importFromGlobKey(schemaValue, '_structures_from_glob', '_structures', false);
75
84
  await this.processInputsKey(schemaValue._inputs);
76
85
  await this.processStructuresKey(schemaValue._structures);
86
+ if (isObject(schemaValue.create)) {
87
+ await this.importFromGlobKey(schemaValue.create, '_inputs_from_glob', '_inputs', false);
88
+ await this.importFromGlobKey(schemaValue.create, '_structures_from_glob', '_structures', false);
89
+ await this.processInputsKey(schemaValue.create._inputs);
90
+ await this.processStructuresKey(schemaValue.create._structures);
91
+ }
77
92
  }
78
93
  }
79
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcannon/configuration-loader",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Load and merge CloudCannon configuration files",
5
5
  "type": "module",
6
6
  "engines": {
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "homepage": "https://cloudcannon.com/documentation/articles/why-split-your-configuration-file/",
54
54
  "dependencies": {
55
- "@cloudcannon/configuration-types": "0.0.56"
55
+ "@cloudcannon/configuration-types": "0.0.58"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "js-yaml": "^4.0.0"