esbuild-plugin-scriptable
Advanced tools
Comparing version 0.6.5 to 0.6.6
@@ -38,45 +38,29 @@ 'use strict'; | ||
build.onResolve({ filter: /.*/ }, async (args) => { | ||
if (!utils.isMatch(args.path, patterns)) { | ||
if (args.kind !== "entry-point" || !utils.isMatch(args.path, patterns)) { | ||
return null; | ||
} | ||
const normalizedPath = utils.normalizeAndResolvePath(args.path); | ||
const isEntryPoint = (() => { | ||
const entryPoints = build.initialOptions.entryPoints; | ||
if (!entryPoints) return false; | ||
if (Array.isArray(entryPoints)) { | ||
return entryPoints.some((entry) => { | ||
const entryPath = utils.normalizeAndResolvePath(String(entry)); | ||
return entryPath === normalizedPath; | ||
}); | ||
} | ||
if (typeof entryPoints === "object") { | ||
return Object.values(entryPoints).some((entry) => { | ||
const entryPath = utils.normalizeAndResolvePath(String(entry)); | ||
return entryPath === normalizedPath; | ||
}); | ||
} | ||
return false; | ||
})(); | ||
if (isEntryPoint) { | ||
const dir = path.dirname(args.path); | ||
const baseFileName = path.basename(args.path).replace(/\.[tj]sx?$/, ""); | ||
const manifestPath = getManifestPath ? getManifestPath(args.path) : manifestExtensions.map((ext) => path.resolve(dir, `${baseFileName}${ext}`)).find(fs.existsSync); | ||
if (manifestPath) { | ||
if (manifestCache.has(normalizedPath)) { | ||
return null; | ||
} | ||
const dir = path.dirname(args.path); | ||
const baseFileName = path.basename(args.path).replace(/\.[tj]sx?$/, ""); | ||
const manifestPath = getManifestPath ? getManifestPath(args.path) : manifestExtensions.map((ext) => path.resolve(dir, `${baseFileName}${ext}`)).find(fs.existsSync); | ||
if (manifestPath) { | ||
try { | ||
const manifestContent = await promises.readFile(manifestPath, "utf8"); | ||
const manifest = normalizeManifest.normalizeManifest(JSON.parse(manifestContent)); | ||
try { | ||
const manifestContent = await promises.readFile(manifestPath, "utf8"); | ||
const manifest = normalizeManifest.normalizeManifest(JSON.parse(manifestContent)); | ||
try { | ||
validateManifest.validateManifest(manifest, allowExtraManifestKeys); | ||
manifestCache.set(normalizedPath, manifest); | ||
} catch (error) { | ||
if (warnOnInvalidManifest && error instanceof Error) { | ||
logger$1.warn(`Invalid manifest file: ${manifestPath} - ${error.message}`, error); | ||
} | ||
validateManifest.validateManifest(manifest, allowExtraManifestKeys); | ||
manifestCache.set(normalizedPath, manifest); | ||
} catch (error) { | ||
if (warnOnInvalidManifest && error instanceof Error) { | ||
logger$1.warn(`Invalid manifest file: ${manifestPath} - ${error.message}`, error); | ||
} | ||
} catch (error) { | ||
logger$1.warn(`Failed to read manifest file: ${manifestPath}`, error); | ||
} | ||
} else if (warnOnMissingManifest) { | ||
logger$1.warn(`No manifest file found for entry point: ${args.path}`); | ||
} catch (error) { | ||
logger$1.warn(`Failed to read manifest file: ${manifestPath}`, error); | ||
} | ||
} else if (warnOnMissingManifest) { | ||
logger$1.warn(`No manifest file found for entry point: ${args.path}`); | ||
} | ||
@@ -83,0 +67,0 @@ return null; |
@@ -25,50 +25,33 @@ import { generateScriptableBanner } from "@scriptables/manifest/generateScriptableBanner"; | ||
build.onResolve({ filter: /.*/ }, async (args) => { | ||
if (!isMatch(args.path, patterns)) { | ||
if (args.kind !== "entry-point" || !isMatch(args.path, patterns)) { | ||
return null; | ||
} | ||
const normalizedPath = normalizeAndResolvePath(args.path); | ||
const isEntryPoint = (() => { | ||
const entryPoints = build.initialOptions.entryPoints; | ||
if (!entryPoints) | ||
return false; | ||
if (Array.isArray(entryPoints)) { | ||
return entryPoints.some((entry) => { | ||
const entryPath = normalizeAndResolvePath(String(entry)); | ||
return entryPath === normalizedPath; | ||
}); | ||
} | ||
if (typeof entryPoints === "object") { | ||
return Object.values(entryPoints).some((entry) => { | ||
const entryPath = normalizeAndResolvePath(String(entry)); | ||
return entryPath === normalizedPath; | ||
}); | ||
} | ||
return false; | ||
})(); | ||
if (isEntryPoint) { | ||
const dir = dirname(args.path); | ||
const baseFileName = basename(args.path).replace(/\.[tj]sx?$/, ""); | ||
const manifestPath = getManifestPath ? getManifestPath(args.path) : manifestExtensions.map((ext) => resolve(dir, `${baseFileName}${ext}`)).find(existsSync); | ||
if (manifestPath) { | ||
if (manifestCache.has(normalizedPath)) { | ||
return null; | ||
} | ||
const dir = dirname(args.path); | ||
const baseFileName = basename(args.path).replace(/\.[tj]sx?$/, ""); | ||
const manifestPath = getManifestPath ? getManifestPath(args.path) : manifestExtensions.map((ext) => resolve(dir, `${baseFileName}${ext}`)).find(existsSync); | ||
if (manifestPath) { | ||
try { | ||
const manifestContent = await readFile(manifestPath, "utf8"); | ||
const manifest = normalizeManifest(JSON.parse(manifestContent)); | ||
try { | ||
const manifestContent = await readFile(manifestPath, "utf8"); | ||
const manifest = normalizeManifest(JSON.parse(manifestContent)); | ||
try { | ||
validateManifest(manifest, allowExtraManifestKeys); | ||
manifestCache.set(normalizedPath, manifest); | ||
} | ||
catch (error) { | ||
if (warnOnInvalidManifest && error instanceof Error) { | ||
logger.warn(`Invalid manifest file: ${manifestPath} - ${error.message}`, error); | ||
} | ||
} | ||
validateManifest(manifest, allowExtraManifestKeys); | ||
manifestCache.set(normalizedPath, manifest); | ||
} | ||
catch (error) { | ||
logger.warn(`Failed to read manifest file: ${manifestPath}`, error); | ||
if (warnOnInvalidManifest && error instanceof Error) { | ||
logger.warn(`Invalid manifest file: ${manifestPath} - ${error.message}`, error); | ||
} | ||
} | ||
} | ||
else if (warnOnMissingManifest) { | ||
logger.warn(`No manifest file found for entry point: ${args.path}`); | ||
catch (error) { | ||
logger.warn(`Failed to read manifest file: ${manifestPath}`, error); | ||
} | ||
} | ||
else if (warnOnMissingManifest) { | ||
logger.warn(`No manifest file found for entry point: ${args.path}`); | ||
} | ||
return null; | ||
@@ -75,0 +58,0 @@ }); |
{ | ||
"name": "esbuild-plugin-scriptable", | ||
"description": "An ESBuild plugin for developing Scriptable iOS app scripts with TypeScript, manifest support and auto-deployment", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "scriptable", |
@@ -70,3 +70,3 @@ import type {ScriptableManifest} from '@scriptables/manifest'; | ||
build.onResolve({filter: /.*/}, async args => { | ||
if (!isMatch(args.path, patterns)) { | ||
if (args.kind !== 'entry-point' || !isMatch(args.path, patterns)) { | ||
return null; | ||
@@ -77,52 +77,31 @@ } | ||
const isEntryPoint = (() => { | ||
const entryPoints = build.initialOptions.entryPoints; | ||
if (!entryPoints) return false; | ||
if (manifestCache.has(normalizedPath)) { | ||
return null; | ||
} | ||
if (Array.isArray(entryPoints)) { | ||
return entryPoints.some(entry => { | ||
const entryPath = normalizeAndResolvePath(String(entry)); | ||
const dir = dirname(args.path); | ||
const baseFileName = basename(args.path).replace(/\.[tj]sx?$/, ''); | ||
return entryPath === normalizedPath; | ||
}); | ||
} | ||
const manifestPath = getManifestPath | ||
? getManifestPath(args.path) | ||
: manifestExtensions.map(ext => resolve(dir, `${baseFileName}${ext}`)).find(existsSync); | ||
if (typeof entryPoints === 'object') { | ||
return Object.values(entryPoints).some(entry => { | ||
const entryPath = normalizeAndResolvePath(String(entry)); | ||
if (manifestPath) { | ||
try { | ||
const manifestContent = await readFile(manifestPath, 'utf8'); | ||
const manifest = normalizeManifest(JSON.parse(manifestContent)); | ||
return entryPath === normalizedPath; | ||
}); | ||
} | ||
return false; | ||
})(); | ||
if (isEntryPoint) { | ||
const dir = dirname(args.path); | ||
const baseFileName = basename(args.path).replace(/\.[tj]sx?$/, ''); | ||
const manifestPath = getManifestPath | ||
? getManifestPath(args.path) | ||
: manifestExtensions.map(ext => resolve(dir, `${baseFileName}${ext}`)).find(existsSync); | ||
if (manifestPath) { | ||
try { | ||
const manifestContent = await readFile(manifestPath, 'utf8'); | ||
const manifest = normalizeManifest(JSON.parse(manifestContent)); | ||
try { | ||
validateManifest(manifest, allowExtraManifestKeys); | ||
manifestCache.set(normalizedPath, manifest); | ||
} catch (error) { | ||
if (warnOnInvalidManifest && error instanceof Error) { | ||
logger.warn(`Invalid manifest file: ${manifestPath} - ${error.message}`, error); | ||
} | ||
validateManifest(manifest, allowExtraManifestKeys); | ||
manifestCache.set(normalizedPath, manifest); | ||
} catch (error) { | ||
if (warnOnInvalidManifest && error instanceof Error) { | ||
logger.warn(`Invalid manifest file: ${manifestPath} - ${error.message}`, error); | ||
} | ||
} catch (error) { | ||
logger.warn(`Failed to read manifest file: ${manifestPath}`, error); | ||
} | ||
} else if (warnOnMissingManifest) { | ||
logger.warn(`No manifest file found for entry point: ${args.path}`); | ||
} catch (error) { | ||
logger.warn(`Failed to read manifest file: ${manifestPath}`, error); | ||
} | ||
} else if (warnOnMissingManifest) { | ||
logger.warn(`No manifest file found for entry point: ${args.path}`); | ||
} | ||
@@ -129,0 +108,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
124581
1318