Skip to content

Commit

Permalink
npm: success
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jan 9, 2025
1 parent 15a9019 commit 47fcd1b
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions scripts/test-package-manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ async function fixManifest(projectDir) {
return tars.find((name) => name.startsWith(hyphenated));
}

// TODO:
for (let [depName, version] of Object.entries(json.devDependencies)) {
if (!version.includes('workspace')) {
continue;
}

let local = tarByPrefix(depName.replace('@', '').replace('/', '-'));

json.devDependencies[depName] = local;
}

writeFileSync(manifestPath, JSON.stringify(json, null, 2));
}
Expand All @@ -98,6 +106,9 @@ async function fixTSConfig(projectDir) {

delete json.references;

json.glint = {
environment: [],
};
json.compilerOptions.paths = {
'vite-basic-compat/*': ['./app/*'],
'vite-basic-compat/tests/*': ['./tess/*'],
Expand All @@ -119,6 +130,7 @@ async function install(packageManager, cwd) {
}

async function typecheck(packageManager, cwd) {
banner('typecheck');
switch (packageManager) {
case 'npm':
return await $({ preferLocal: true, shell: true, cwd, stdio: 'inherit' })`npm exec glint`;
Expand All @@ -129,13 +141,25 @@ async function typecheck(packageManager, cwd) {
}
}
async function build(packageManager, cwd) {
banner('build');
return await $({ preferLocal: true, shell: true, cwd, stdio: 'inherit' })`${packageManager} run build`;
}

async function test(packageManager, cwd) {
banner('test');
return await $({ preferLocal: true, shell: true, cwd, stdio: 'inherit' })`${packageManager} run test:vite`;
}

function banner(text) {
console.info(`
--------------------------------
${text}
--------------------------------
`);
}

async function main() {
const [, , packageManager] = process.argv;

Expand All @@ -156,9 +180,18 @@ async function main() {
await fixManifest(projectDir);
await fixTSConfig(projectDir);
await install(packageManager, projectDir);
await typecheck(packageManager, projectDir);
await build(packageManager, projectDir);
await test(packageManager, projectDir);
let typesResult = await typecheck(packageManager, projectDir);
let buildResult = await build(packageManager, projectDir);
let testResult = await test(packageManager, projectDir);

console.info(`
Using: ${packageManager};
In: ${projectDir}
types: ${typesResult.exitCode === 0 ? 'Success' : 'Failure'}
build: ${buildResult.exitCode === 0 ? 'Success' : 'Failure'}
test: ${testResult.exitCode === 0 ? 'Success' : 'Failure'}
`);
}

await main();

0 comments on commit 47fcd1b

Please sign in to comment.