-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix linting, fix index exports, fix generate-exports script
- Loading branch information
1 parent
9a6890f
commit 5496c22
Showing
16 changed files
with
108 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import packageJson from '../package.json' assert { type: 'json' }; | ||
|
||
// Define the directory and file paths | ||
const filtersDirPath = path.resolve('src'); | ||
const packageJsonPath = path.resolve('package.json'); | ||
|
||
// Ensure the exports field exists | ||
packageJson.exports = packageJson.exports ?? {}; | ||
|
||
packageJson.exports['.'] = { | ||
import: './lib/index.mjs', | ||
require: './lib/index.js', | ||
types: './lib/index.d.ts', | ||
}; | ||
|
||
// Read all directories in the filters folder | ||
fs.readdirSync(filtersDirPath, { withFileTypes: true }) | ||
.filter((dirent) => dirent.isDirectory()) | ||
.forEach((dirent) => | ||
{ | ||
// Add each directory to the exports field | ||
const dirName = dirent.name; | ||
|
||
packageJson.exports[`./${dirName}`] = { | ||
import: `./lib/${dirName}.mjs`, | ||
require: `./lib/${dirName}.js`, | ||
types: `./lib/${dirName}.d.ts`, | ||
}; | ||
}); | ||
|
||
async function fileExists(filePath) | ||
{ | ||
try | ||
{ | ||
fs.accessSync(path.resolve(filePath)); | ||
|
||
return true; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
function validateExports(exports) | ||
{ | ||
return Promise.all( | ||
Object.entries(exports).map(async ([key, value]) => | ||
{ | ||
const { import: importPath, require: requirePath, types: typesPath } = value; | ||
|
||
if (!importPath || !(await fileExists(importPath))) | ||
{ | ||
throw new Error(`The import path "${importPath}" for "${key}" does not exist.`); | ||
} | ||
|
||
if (!requirePath || !(await fileExists(requirePath))) | ||
{ | ||
throw new Error(`The require path "${requirePath}" for "${key}" does not exist.`); | ||
} | ||
|
||
if (!typesPath || !(await fileExists(typesPath))) | ||
{ | ||
throw new Error(`The types path "${typesPath}" for "${key}" does not exist.`); | ||
} | ||
}) | ||
); | ||
} | ||
|
||
try | ||
{ | ||
await validateExports(packageJson.exports); | ||
// Write the updated package.json back to disk | ||
fs.promises.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
} | ||
catch (error) | ||
{ | ||
console.error(`ERROR: ${error.message}\n`); | ||
process.exit(1); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './AdjustmentFilter.js'; | ||
export * from './AdjustmentFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './ColorMapFilter.js'; | ||
export * from './ColorMapFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './CRTFilter.js'; | ||
export * from './CRTFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './GlitchFilter.js'; | ||
export * from './GlitchFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './KawaseBlurFilter.js'; | ||
export * from './KawaseBlurFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './MotionBlurFilter.js'; | ||
export * from './MotionBlurFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './MultiColorReplaceFilter.js'; | ||
export * from './MultiColorReplaceFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './OldFilmFilter.js'; | ||
export * from './OldFilmFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './RadialBlurFilter.js'; | ||
export * from './RadialBlurFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './ReflectionFilter.js'; | ||
export * from './ReflectionFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './ZoomBlurFilter.js'; | ||
export * from './ZoomBlurFilter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"func-names": "off" | ||
} | ||
} |