-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1622 from glimmerjs/meta-compile
Add CI step for verifying that unwanted code does not get published
- Loading branch information
Showing
6 changed files
with
120 additions
and
44 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 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 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,55 @@ | ||
import { globby } from 'globby'; | ||
import { readFile } from 'node:fs/promises'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { resolve } from 'node:path'; | ||
|
||
const currentDir = fileURLToPath(import.meta.url); | ||
const FORBIDDEN = [ | ||
/** | ||
* import.meta.env is not a platform standard | ||
*/ | ||
'import.meta.env', | ||
/** | ||
* These variables are wrapped around code for this repo only | ||
*/ | ||
'VM_LOCAL', | ||
/** | ||
* These are for local VM debugging and development, and are not meant to make it to real code | ||
*/ | ||
'check(', | ||
'CheckInterface', | ||
'CheckOr', | ||
'CheckFunction', | ||
'CheckObject', | ||
]; | ||
|
||
const IGNORED_DIRS = [`@glimmer/syntax`, `@glimmer/debug`]; | ||
|
||
let files = await globby(resolve(currentDir, '../../packages/**/dist/**/index.js'), { | ||
ignore: ['node_modules', '**/node_modules'], | ||
}); | ||
|
||
files = files.filter((file) => !IGNORED_DIRS.some((dir) => file.includes(dir))); | ||
|
||
let errors = []; | ||
|
||
console.log(`Found ${files.length} files to check...`); | ||
|
||
for (let filePath of files) { | ||
console.log(`Checking ${filePath}...`); | ||
let file = await readFile(filePath); | ||
let content = file.toString(); | ||
|
||
for (let searchFor of FORBIDDEN) { | ||
if (content.includes(searchFor)) { | ||
errors.push({ filePath, found: searchFor }); | ||
} | ||
} | ||
} | ||
|
||
if (errors.length > 0) { | ||
console.error(errors); | ||
throw new Error(`The forbidden texts were encountered in the above files`); | ||
} | ||
|
||
console.info('No forbidden texts!'); |
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 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
Oops, something went wrong.