-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve type smoke tests (not finished yet)
- Loading branch information
Showing
16 changed files
with
288 additions
and
134 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,93 @@ | ||
#!/usr/bin/env node | ||
import { rimraf } from 'rimraf'; | ||
|
||
await rimraf('**/{dist,.turbo,node_modules}/', { glob: true }); | ||
function parseArgs() { | ||
const args = process.argv.slice(2); | ||
const options = { | ||
preserve: new Set(), | ||
help: false, | ||
dryRun: false | ||
}; | ||
|
||
for (let i = 0; i < args.length; i++) { | ||
const arg = args[i]; | ||
switch (arg) { | ||
case '--preserve': | ||
const value = args[++i]; | ||
if (!value || value.startsWith('--')) { | ||
console.error('Error: --preserve requires a value (node-modules, turbo, or both)'); | ||
process.exit(1); | ||
} | ||
const items = value.split(','); | ||
for (const item of items) { | ||
if (!['node-modules', 'turbo'].includes(item)) { | ||
console.error(`Error: Invalid preserve value: ${item}. Must be 'node-modules' or 'turbo'`); | ||
process.exit(1); | ||
} | ||
options.preserve.add(item); | ||
} | ||
break; | ||
case '--dry-run': | ||
options.dryRun = true; | ||
break; | ||
case '--help': | ||
case '-h': | ||
options.help = true; | ||
break; | ||
default: | ||
console.warn(`Unknown option: ${arg}`); | ||
} | ||
} | ||
|
||
return options; | ||
} | ||
|
||
function showHelp() { | ||
console.log(` | ||
Usage: clean.mjs [options] | ||
Options: | ||
--preserve <items> Skip cleaning specified items (comma-separated) | ||
Valid values: node-modules, turbo | ||
Example: --preserve node-modules,turbo | ||
--dry-run Show what would be deleted without actually deleting | ||
--help, -h Show this help message | ||
Description: | ||
Cleans build artifacts and dependencies from the project. | ||
By default removes dist, .turbo, and node_modules directories. | ||
`); | ||
} | ||
|
||
async function main() { | ||
const options = parseArgs(); | ||
|
||
if (options.help) { | ||
showHelp(); | ||
process.exit(0); | ||
} | ||
|
||
const patterns = ['**/dist/']; | ||
if (!options.preserve.has('node-modules')) patterns.push('**/node_modules/'); | ||
if (!options.preserve.has('turbo')) patterns.push('**/.turbo/'); | ||
|
||
const glob = `{${patterns.join(',')}}`; | ||
|
||
if (options.dryRun) { | ||
console.log('Would delete the following pattern:', glob); | ||
process.exit(0); | ||
} | ||
|
||
try { | ||
await rimraf(glob, { glob: true }); | ||
console.log('Clean completed successfully'); | ||
} catch (error) { | ||
console.error('Error during cleanup:', error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main().catch(error => { | ||
console.error('Fatal error:', error); | ||
process.exit(1); | ||
}); |
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 @@ | ||
import "@glimmer/runtime"; |
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,12 @@ | ||
{ | ||
"private": true, | ||
"name": "@glimmer-workspace/smoke-types", | ||
"main": "index.ts", | ||
"scripts": { | ||
"test:lint": "eslint .", | ||
"test:types": "tsc --noEmit -p ../tsconfig.json" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^8.52.0" | ||
} | ||
} |
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,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"noEmit": true, | ||
"target": "esnext", | ||
"module": "esnext", | ||
"moduleResolution": "bundler", | ||
"baseUrl": ".", | ||
"strict": true, | ||
"paths": { | ||
"@glimmer/*": [ | ||
"../../@glimmer/*/dist/prod/index.d.ts" | ||
], | ||
}, | ||
"skipLibCheck": true | ||
}, | ||
"files": [ | ||
"index.ts" | ||
] | ||
} |
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
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.