@blocklet/pages-kit-block-studio 0.4.142 → 0.4.144

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.
@@ -219,7 +219,9 @@ exports.initBlockStudioRouter.post('/create', async (req, res) => {
219
219
  });
220
220
  exports.initBlockStudioRouter.get('/resources', async (req, res) => {
221
221
  const { withBlockletData = true } = req.query;
222
- const allBlocks = await (0, helper_1.findComponentFiles)();
222
+ const allBlocks = await (0, helper_1.findComponentFiles)({
223
+ strictExistMetadata: true,
224
+ });
223
225
  // get code to metadata
224
226
  const allBlocksWithCode = allBlocks.map((block) => {
225
227
  const code = (0, helper_1.getBlockCode)(block.fullPath);
@@ -247,7 +249,9 @@ exports.initBlockStudioRouter.get('/resources', async (req, res) => {
247
249
  return res.json((0, keyBy_1.default)(allBlocksWithCode, 'id'));
248
250
  });
249
251
  exports.initBlockStudioRouter.get('/components', async (_req, res) => {
250
- const allBlocks = await (0, helper_1.findComponentFiles)();
252
+ const allBlocks = await (0, helper_1.findComponentFiles)({
253
+ strictExistMetadata: true,
254
+ });
251
255
  return res.json(allBlocks);
252
256
  });
253
257
  // 统一的属性到接口转换端点 - 可以预览或生成
@@ -97,7 +97,7 @@ exports.initResourceRouter = (0, express_1.Router)();
97
97
  exports.initResourceRouter.get('/', async (_req, res) => {
98
98
  const resources = [];
99
99
  const rootDir = process.cwd();
100
- const files = (0, helper_1.findComponentFiles)({ cwd: rootDir });
100
+ const files = (0, helper_1.findComponentFiles)({ cwd: rootDir, strictExistMetadata: true });
101
101
  for (const file of files) {
102
102
  // const filePath = path.join(rootDir, file);
103
103
  // const fileContent = fs.readFileSync(filePath, 'utf8');
@@ -176,7 +176,7 @@ exports.initResourceRouter.post('/', async (req, res) => {
176
176
  const chunksMapPath = (0, path_1.join)(codeDir, 'chunks-map.json');
177
177
  const chunksMap = JSON.parse(fs_1.default.readFileSync(chunksMapPath, 'utf8'));
178
178
  // get @metadata.json by glob
179
- const canUseComponents = (0, helper_1.findComponentFiles)({ cwd: rootDir, filter: componentIds });
179
+ const canUseComponents = (0, helper_1.findComponentFiles)({ cwd: rootDir, filter: componentIds, strictExistMetadata: true });
180
180
  // Filter and process metadata files
181
181
  const metadataList = canUseComponents.map(({ fullPath, blockName, metadata: _metadata }) => {
182
182
  // get metadata