@mfeflow/core 0.1.0 → 0.2.0

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.
Files changed (2) hide show
  1. package/dist/index.js +20 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1921,6 +1921,7 @@ function assertThirdPartyContent(manifest, label) {
1921
1921
  if (manifest.name.startsWith('@mfeflow/') || !manifest.name.startsWith('@')) throw new MfeflowError('E203', `${label}: third-party features must be namespaced and cannot use @mfeflow`);
1922
1922
  for (const file of manifest.files ?? []){
1923
1923
  if (void 0 !== file.from) throw new MfeflowError('E203', `${label}: "${file.to}" reads a local file (from); use inline content`);
1924
+ if (file.atRoot) throw new MfeflowError('E203', `${label}: "${file.to}" uses atRoot, which is first-party only`);
1924
1925
  assertThirdPartyPath(file.to, file.to);
1925
1926
  }
1926
1927
  for (const t of manifest.transforms ?? []){
@@ -1929,7 +1930,10 @@ function assertThirdPartyContent(manifest, label) {
1929
1930
  ];
1930
1931
  for (const file of files)assertThirdPartyPath(file, file);
1931
1932
  }
1932
- for (const dep of manifest.dependencies ?? [])if (!isRegistryRange(dep.range)) throw new MfeflowError('E203', `${label}: ${dep.name}@${dep.range} is not a registry version range`);
1933
+ for (const dep of manifest.dependencies ?? []){
1934
+ if (dep.name.includes('{{')) throw new MfeflowError('E203', `${label}: ${dep.name} names a package in the project's scope`);
1935
+ if (!isRegistryRange(dep.range)) throw new MfeflowError('E203', `${label}: ${dep.name}@${dep.range} is not a registry version range`);
1936
+ }
1933
1937
  for (const t of manifest.transforms ?? [])assertThirdPartyTransform(t, label);
1934
1938
  for (const script of manifest.scripts ?? [])assertPlainScript(script.name, label);
1935
1939
  }
@@ -2068,6 +2072,9 @@ function resolveOptions(manifest, given = {}) {
2068
2072
  function applies(part, options, present) {
2069
2073
  return Object.entries(part.when ?? {}).every(([name, value])=>name.startsWith(FEATURE_CONDITION) ? present.has(name.slice(FEATURE_CONDITION.length)) === value : options[name] === value);
2070
2074
  }
2075
+ function fill(text, data, label) {
2076
+ return text.includes('{{') ? substitute(text, data, label) : text;
2077
+ }
2071
2078
  function resolve_assertWritable(file, relative, trusted) {
2072
2079
  if (!isSafeRelativePath(file)) throw new MfeflowError('E105', `"${file}"`);
2073
2080
  if (trusted) assertWritable(file);
@@ -2112,14 +2119,21 @@ async function resolveFeature(input) {
2112
2119
  }
2113
2120
  });
2114
2121
  const steps = [];
2115
- for (const file of (manifest.files ?? []).filter((f)=>applies(f, options, present)))for (const place of placesFor(file.target, project)){
2116
- const to = joinPosix(place.dir, file.to);
2117
- resolve_assertWritable(to, file.to, trusted);
2118
- steps.push(async ()=>builder.create(to, await contentOf(file, feature, dataFor(place))));
2122
+ for (const file of (manifest.files ?? []).filter((f)=>applies(f, options, present))){
2123
+ if (file.atRoot && !trusted) throw new MfeflowError('E203', `${manifest.name}: "${file.to}" uses atRoot, which only features that ship with mfeflow may`);
2124
+ for (const place of placesFor(file.target, project)){
2125
+ const data = dataFor(place);
2126
+ const relative = fill(file.to, data, `${manifest.name}:${file.to}`);
2127
+ const to = file.atRoot ? relative : joinPosix(place.dir, relative);
2128
+ resolve_assertWritable(to, relative, trusted);
2129
+ steps.push(async ()=>builder.create(to, await contentOf(file, feature, data)));
2130
+ }
2119
2131
  }
2120
2132
  for (const dep of (manifest.dependencies ?? []).filter((d)=>applies(d, options, present)))for (const place of placesFor(dep.target, project)){
2121
2133
  const pkg = joinPosix(place.dir, 'package.json');
2122
- steps.push(()=>builder.addDependency(pkg, dep.name, dep.range, dep.dev));
2134
+ if (!trusted && dep.name.includes('{{')) throw new MfeflowError('E203', `${manifest.name}: ${dep.name} is for first-party features`);
2135
+ const name = fill(dep.name, dataFor(place), `${manifest.name}:${dep.name}`);
2136
+ steps.push(()=>builder.addDependency(pkg, name, dep.range, dep.dev));
2123
2137
  }
2124
2138
  for (const script of (manifest.scripts ?? []).filter((x)=>applies(x, options, present)))for (const place of placesFor(script.target, project)){
2125
2139
  const pkg = joinPosix(place.dir, 'package.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mfeflow/core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "The engine behind the mfeflow CLI: project model, change plans with diffs, atomic apply with rollback, and feature resolution.",
5
5
  "keywords": [
6
6
  "micro-frontend",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@babel/parser": "8.0.10",
47
47
  "@babel/types": "8.0.10",
48
- "@mfeflow/contracts": "0.1.0",
48
+ "@mfeflow/contracts": "0.2.0",
49
49
  "diff": "9.0.0",
50
50
  "eta": "4.6.0",
51
51
  "semver": "7.8.5",