generated from darkobits/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
536 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,62 @@ | ||
import { nr } from '@darkobits/ts'; | ||
|
||
export default nr(); | ||
|
||
export default nr(({ script, command }) => { | ||
script('test.smoke', { | ||
group: 'Testing', | ||
run: [ | ||
[ | ||
// ----- CJS Tests ----------------------------------------------------- | ||
|
||
// esbuild | ||
command.node('smoke-test', ['test.js'], { | ||
execaOptions: { cwd: 'smoke-tests/cjs/ts-extension' } | ||
}), | ||
|
||
// esbuild | ||
command.node('smoke-test', ['test.js'], { | ||
execaOptions: { cwd: 'smoke-tests/cjs/mts-extension' } | ||
}), | ||
|
||
// import() | ||
command.node('smoke-test', ['test.js'], { | ||
execaOptions: { cwd: 'smoke-tests/cjs/mjs-extension' } | ||
}), | ||
|
||
// esbuild, issues node:35129 warning | ||
command.node('smoke-test', ['test.js'], { | ||
execaOptions: { cwd: 'smoke-tests/cjs/js-extension' } | ||
}), | ||
|
||
|
||
// ----- ESM Tests ----------------------------------------------------- | ||
|
||
// esbuild | ||
command.node('smoke-test', ['test.js'], { | ||
execaOptions: { cwd: 'smoke-tests/esm/ts-extension' } | ||
}), | ||
|
||
// import() | ||
command.node('smoke-test', ['test.js'], { | ||
execaOptions: { cwd: 'smoke-tests/esm/js-extension' } | ||
}), | ||
|
||
// esbuild, issues node:35129 warning | ||
command.node('smoke-test', ['test.js'], { | ||
execaOptions: { cwd: 'smoke-tests/esm/cjs-extension' } | ||
}), | ||
|
||
// esbuild | ||
command.node('smoke-test', ['test.js'], { | ||
execaOptions: { cwd: 'smoke-tests/esm/cts-extension' } | ||
}) | ||
] | ||
], | ||
timing: true | ||
}); | ||
|
||
script('postPrepare', { | ||
run: ['script:test.smoke'] | ||
}); | ||
|
||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,6 @@ | ||
## Smoke Tests | ||
|
||
These tests are designed to be run _after_ the project has successfully been built. They are designed to | ||
ensure that Saffron can successfully load configuration files in various formats with ESM host projects | ||
and CommonJS host projects. These tests can be run via the `test.smoke` package script and are run | ||
automatically in CI. |
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,3 @@ | ||
module.exports = { | ||
foo: 'bar' | ||
}; |
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,4 @@ | ||
{ | ||
"name": "app", | ||
"type": "commonjs" | ||
} |
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,40 @@ | ||
const os = require('os'); | ||
|
||
const LogFactory = require('@darkobits/log'); | ||
|
||
const log = LogFactory({ heading: 'smokeTest' }); | ||
|
||
/** | ||
* Loading an Implicitly CJS Configuration File in a CJS Project | ||
* | ||
* This tests that: | ||
* | ||
* 1. Saffron (an ESM package) can be dynamically-imported in a CJS package. | ||
* 2. Saffron can locate and parse a configuration file with a .js extension | ||
* where said file will be transpiled to CJS (because this package does not | ||
* declare type:module). | ||
*/ | ||
async function implicitCjs() { | ||
try { | ||
const cli = await import('../../../dist/index.js'); | ||
|
||
cli.command({ | ||
handler: ({ config }) => { | ||
if (config && Object.keys(config).length > 0) { | ||
log.verbose(log.prefix('cjs:js-extension'), log.chalk.green('success')); | ||
} else { | ||
throw new Error('No config found.'); | ||
} | ||
} | ||
}); | ||
|
||
cli.init(); | ||
} catch (err) { | ||
log.error(log.prefix('cjs:js-extension'), log.chalk.gray(err.message.replaceAll(os.EOL, ' '))); | ||
log.verbose(err.stack); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
|
||
void implicitCjs(); |
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,3 @@ | ||
export default { | ||
foo: 'bar' | ||
}; |
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,4 @@ | ||
{ | ||
"name": "app", | ||
"type": "commonjs" | ||
} |
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,41 @@ | ||
const os = require('os'); | ||
|
||
const LogFactory = require('@darkobits/log'); | ||
|
||
const log = LogFactory({ heading: 'smokeTest' }); | ||
|
||
/** | ||
* Loading an Explicitly ESM Configuration File in a CJS Project | ||
* This tests that: | ||
* | ||
* 1. Saffron (an ESM package) can be dynamically-imported in a CJS package. | ||
* 2. Saffron can locate and parse a configuration file with an .mjs extension | ||
* where said file will be transpiled to ESM. | ||
* | ||
* Note that Saffron should be able to dynamically import this file without | ||
* having to resort to more exotic transpilation strategies. | ||
*/ | ||
async function explicitEsm() { | ||
try { | ||
const cli = await import('../../../dist/index.js'); | ||
|
||
cli.command({ | ||
handler: ({ config }) => { | ||
if (config && Object.keys(config).length > 0) { | ||
log.verbose(log.prefix('cjs:mjs-extension'), log.chalk.green('success')); | ||
} else { | ||
throw new Error('No config found.'); | ||
} | ||
} | ||
}); | ||
|
||
cli.init(); | ||
} catch (err) { | ||
log.error(log.prefix('cjs:mjs-extension'), log.chalk.gray(err.message.replaceAll(os.EOL, ' '))); | ||
log.verbose(err.stack); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
|
||
void explicitEsm(); |
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,3 @@ | ||
export default { | ||
foo: 'bar' | ||
}; |
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,4 @@ | ||
{ | ||
"name": "app", | ||
"type": "commonjs" | ||
} |
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,40 @@ | ||
const os = require('os'); | ||
|
||
const LogFactory = require('@darkobits/log'); | ||
|
||
const log = LogFactory({ heading: 'smokeTest' }); | ||
|
||
/** | ||
* Loading a TypeScript Configuration File in a CJS Project | ||
* | ||
* This tests that: | ||
* | ||
* 1. Saffron (an ESM package) can be dynamically-imported in a CJS package. | ||
* 2. Saffron can locate and parse a configuration file with an .mts extension | ||
* where said file will be transpiled to ESM (because it has an .mjs | ||
* extension). | ||
*/ | ||
async function mtsToCjs() { | ||
try { | ||
const cli = await import('../../../dist/index.js'); | ||
|
||
cli.command({ | ||
handler: ({ config }) => { | ||
if (config && Object.keys(config).length > 0) { | ||
log.verbose(log.prefix('cjs:mts-extension'), log.chalk.green('success')); | ||
} else { | ||
throw new Error('No config found.'); | ||
} | ||
} | ||
}); | ||
|
||
cli.init(); | ||
} catch (err) { | ||
log.error(log.prefix('cjs:mts-extension'), log.chalk.gray(err.message.replaceAll(os.EOL, ' '))); | ||
log.verbose(err.stack); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
|
||
void mtsToCjs(); |
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,7 @@ | ||
{ | ||
"extends": "@darkobits/ts/tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "/dev/null" | ||
} | ||
} |
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,3 @@ | ||
export default { | ||
foo: 'bar' | ||
}; |
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,4 @@ | ||
{ | ||
"name": "app", | ||
"type": "commonjs" | ||
} |
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,41 @@ | ||
const os = require('os'); | ||
|
||
const LogFactory = require('@darkobits/log'); | ||
|
||
const log = LogFactory({ heading: 'smokeTest' }); | ||
|
||
|
||
/** | ||
* Loading a TypeScript Configuration File in a CJS Project | ||
* | ||
* This tests that: | ||
* | ||
* 1. Saffron (an ESM package) can be dynamically-imported in a CJS package. | ||
* 2. Saffron can locate and parse a configuration file with a .ts extension | ||
* where said file will be transpiled to CJS (because this package does not | ||
* declare type:module). | ||
*/ | ||
async function typeScriptToCjs() { | ||
try { | ||
const cli = await import('../../../dist/index.js'); | ||
|
||
cli.command({ | ||
handler: ({ config }) => { | ||
if (config && Object.keys(config).length > 0) { | ||
log.verbose(log.prefix('cjs:ts-extension'), log.chalk.green('success')); | ||
} else { | ||
throw new Error('No config found.'); | ||
} | ||
} | ||
}); | ||
|
||
cli.init(); | ||
} catch (err) { | ||
log.error(log.prefix('cjs:ts-extension'), log.chalk.gray(err.message.replaceAll(os.EOL, ' '))); | ||
log.verbose(err.stack); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
|
||
void typeScriptToCjs(); |
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,7 @@ | ||
{ | ||
"extends": "@darkobits/ts/tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "/dev/null" | ||
} | ||
} |
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,3 @@ | ||
module.exports = { | ||
foo: 'bar' | ||
}; |
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,4 @@ | ||
{ | ||
"name": "app", | ||
"type": "module" | ||
} |
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,39 @@ | ||
import os from 'os'; | ||
|
||
import LogFactory from '@darkobits/log'; | ||
|
||
import * as cli from '../../../dist/index.js'; | ||
|
||
const log = LogFactory({ heading: 'smokeTest' }); | ||
|
||
|
||
/** | ||
* Loading an Explicitly ESM Configuration File in a CJS Project | ||
* This tests that: | ||
* | ||
* 1. Saffron can be imported in an ESM package. | ||
* 2. Saffron can locate and parse a configuration file with a .cjs extension | ||
* where said file will be transpiled to CJS. | ||
*/ | ||
function explicitCjs() { | ||
try { | ||
cli.command({ | ||
handler: ({ config }) => { | ||
if (config && Object.keys(config).length > 0) { | ||
log.verbose(log.prefix('esm:cjs-extension'), log.chalk.green('success')); | ||
} else { | ||
throw new Error('No config found.'); | ||
} | ||
} | ||
}); | ||
|
||
cli.init(); | ||
} catch (err) { | ||
log.error(log.prefix('esm:cjs-extension'), log.chalk.gray(err.message.replaceAll(os.EOL, ' '))); | ||
log.verbose(err.stack); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
|
||
void explicitCjs(); |
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,7 @@ | ||
{ | ||
"extends": "@darkobits/ts/tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "/dev/null" | ||
} | ||
} |
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,3 @@ | ||
module.exports = { | ||
foo: 'bar' | ||
}; |
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,4 @@ | ||
{ | ||
"name": "app", | ||
"type": "module" | ||
} |
Oops, something went wrong.