Skip to content

Commit 489e1fa

Browse files
Merge pull request #1622 from glimmerjs/meta-compile
Add CI step for verifying that unwanted code does not get published
2 parents b1aa902 + ddeeb50 commit 489e1fa

File tree

6 files changed

+120
-44
lines changed

6 files changed

+120
-44
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
node-version: 20.1.0
2929
repo-token: ${{ secrets.GITHUB_TOKEN }}
3030
- run: pnpm turbo build
31+
- run: node ./bin/build-verify.mjs
3132

3233
lint:
3334
name: Linting

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
# This creates an .npmrc that reads the NODE_AUTH_TOKEN environment variable
5858
node-registry-url: 'https://registry.npmjs.org'
5959

60-
- run: pnpm turbo build
60+
- run: pnpm turbo build --force --no-cache
6161
- name: npm publish
6262
run: pnpm release-plan publish
6363
env:

bin/build-verify.mjs

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { globby } from 'globby';
2+
import { readFile } from 'node:fs/promises';
3+
import { fileURLToPath } from 'node:url';
4+
import { resolve } from 'node:path';
5+
6+
const currentDir = fileURLToPath(import.meta.url);
7+
const FORBIDDEN = [
8+
/**
9+
* import.meta.env is not a platform standard
10+
*/
11+
'import.meta.env',
12+
/**
13+
* These variables are wrapped around code for this repo only
14+
*/
15+
'VM_LOCAL',
16+
/**
17+
* These are for local VM debugging and development, and are not meant to make it to real code
18+
*/
19+
'check(',
20+
'CheckInterface',
21+
'CheckOr',
22+
'CheckFunction',
23+
'CheckObject',
24+
];
25+
26+
const IGNORED_DIRS = [`@glimmer/syntax`, `@glimmer/debug`];
27+
28+
let files = await globby(resolve(currentDir, '../../packages/**/dist/**/index.js'), {
29+
ignore: ['node_modules', '**/node_modules'],
30+
});
31+
32+
files = files.filter((file) => !IGNORED_DIRS.some((dir) => file.includes(dir)));
33+
34+
let errors = [];
35+
36+
console.log(`Found ${files.length} files to check...`);
37+
38+
for (let filePath of files) {
39+
console.log(`Checking ${filePath}...`);
40+
let file = await readFile(filePath);
41+
let content = file.toString();
42+
43+
for (let searchFor of FORBIDDEN) {
44+
if (content.includes(searchFor)) {
45+
errors.push({ filePath, found: searchFor });
46+
}
47+
}
48+
}
49+
50+
if (errors.length > 0) {
51+
console.error(errors);
52+
throw new Error(`The forbidden texts were encountered in the above files`);
53+
}
54+
55+
console.info('No forbidden texts!');

bin/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"chalk": "^5.2.0",
1515
"execa": "^7.1.1",
1616
"glob": "^10.2.3",
17+
"globby": "^14.0.2",
1718
"js-yaml": "^4.1.0",
1819
"mkdirp": "^3.0.1",
1920
"puppeteer-chromium-resolver": "^20.0.0",

packages/@glimmer-workspace/build/lib/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ export class Package {
402402
replace({
403403
preventAssignment: true,
404404
values: {
405+
'import.meta.env.MODE': '"development"',
405406
'import.meta.env.DEV': 'DEBUG',
406407
'import.meta.env.PROD': '!DEBUG',
407408
'import.meta.env.VM_LOCAL_DEV': 'false',

0 commit comments

Comments
 (0)