浏览代码

Check that schema and style files are published.

Ian Rose 6 年之前
父节点
当前提交
9c5945d843
共有 1 个文件被更改,包括 23 次插入0 次删除
  1. 23 0
      buildutils/src/ensure-package.ts

+ 23 - 0
buildutils/src/ensure-package.ts

@@ -156,6 +156,18 @@ export async function ensurePackage(
     utils.writeJSONFile(tsConfigPath, tsConfigData);
   }
 
+  // Get a list of all the published files.
+  // This will not catch .js or .d.ts files if they have not been built,
+  // but we primarily use this to check for files that are published as-is,
+  // like styles, assets, and schemas.
+  const published = new Set<string>(
+    data.files
+      ? data.files.reduce((acc: string[], curr: string) => {
+          return acc.concat(glob.sync(path.join(pkgPath, curr)));
+        }, [])
+      : []
+  );
+
   // Ensure that the `schema` directories match what is in the `package.json`
   const schemaDir = data.jupyterlab && data.jupyterlab.schemaDir;
   const schemas = glob.sync(
@@ -166,8 +178,19 @@ export async function ensurePackage(
   } else if (!schemaDir && schemas.length) {
     messages.push(`Schemas found, but no schema indicated in ${pkgPath}`);
   }
+  for (let schema of schemas) {
+    if (!published.has(schema)) {
+      messages.push(`Schema ${schema} not published in ${pkgPath}`);
+    }
+  }
 
   // Ensure that the `style` directories match what is in the `package.json`
+  const styles = glob.sync(path.join(pkgPath, 'style', '**/*.*'));
+  for (let style of styles) {
+    if (!published.has(style)) {
+      messages.push(`Style file ${style} not published in ${pkgPath}`);
+    }
+  }
 
   // Ensure dependencies and dev dependencies.
   data.dependencies = deps;