-
Notifications
You must be signed in to change notification settings - Fork 33
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 #26 from ndaidong/v5.0.0rc1
v5.0.0rc1
- Loading branch information
Showing
27 changed files
with
5,525 additions
and
2,759 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 |
---|---|---|
|
@@ -14,5 +14,6 @@ coverage | |
yarn.lock | ||
coverage.lcov | ||
package-lock.json | ||
pnpm-lock.yaml | ||
|
||
output.json |
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,53 @@ | ||
/** | ||
* build.js | ||
* @ndaidong | ||
**/ | ||
|
||
import { readFileSync, writeFileSync } from 'fs' | ||
import { execSync } from 'child_process' | ||
|
||
import { buildSync } from 'esbuild' | ||
|
||
const pkg = JSON.parse(readFileSync('./package.json')) | ||
|
||
execSync('rm -rf dist') | ||
execSync('mkdir dist') | ||
|
||
const buildTime = (new Date()).toISOString() | ||
const comment = [ | ||
`// ${pkg.name}@${pkg.version}, by ${pkg.author}`, | ||
`built with esbuild at ${buildTime}`, | ||
`published under ${pkg.license} license` | ||
].join(' - ') | ||
|
||
const baseOpt = { | ||
entryPoints: ['src/main.js'], | ||
bundle: true, | ||
charset: 'utf8', | ||
target: ['es2020', 'node14'], | ||
minify: false, | ||
write: true | ||
} | ||
|
||
const cjsVersion = { | ||
...baseOpt, | ||
platform: 'node', | ||
format: 'cjs', | ||
mainFields: ['main'], | ||
outfile: `dist/cjs/${pkg.name}.js`, | ||
banner: { | ||
js: comment | ||
} | ||
} | ||
buildSync(cjsVersion) | ||
|
||
const cjspkg = { | ||
name: pkg.name + '-cjs', | ||
version: pkg.version, | ||
main: `./${pkg.name}.js` | ||
} | ||
writeFileSync( | ||
'dist/cjs/package.json', | ||
JSON.stringify(cjspkg, null, ' '), | ||
'utf8' | ||
) |
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,25 @@ | ||
// release.test | ||
|
||
/* eslint-env jest */ | ||
|
||
import { | ||
existsSync, | ||
readFileSync | ||
} from 'fs' | ||
|
||
const pkg = JSON.parse(readFileSync('./package.json')) | ||
|
||
const cjsFile = `./dist/cjs/${pkg.name}.js` | ||
|
||
describe('Validate commonjs version output', () => { | ||
test(`Check if ${cjsFile} created`, () => { | ||
expect(existsSync(cjsFile)).toBeTruthy() | ||
}) | ||
const constent = readFileSync(cjsFile, 'utf8') | ||
const lines = constent.split('\n') | ||
test('Check if file meta contains package info', () => { | ||
expect(lines[0].includes(`${pkg.name}@${pkg.version}`)).toBeTruthy() | ||
expect(lines[0].includes(pkg.author)).toBeTruthy() | ||
expect(lines[0].includes(pkg.license)).toBeTruthy() | ||
}) | ||
}) |
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,24 @@ | ||
// cjs-eval.js | ||
|
||
const { writeFileSync } = require('fs') | ||
|
||
const { read } = require('./dist/cjs/feed-reader.js') | ||
|
||
const extractFromUrl = async (url) => { | ||
try { | ||
const art = await read(url) | ||
console.log(art) | ||
writeFileSync('./output.json', JSON.stringify(art), 'utf8') | ||
} catch (err) { | ||
console.trace(err) | ||
} | ||
} | ||
|
||
const init = (argv) => { | ||
if (argv.length === 3) { | ||
return extractFromUrl(argv[2]) | ||
} | ||
return 'Nothing to do!' | ||
} | ||
|
||
init(process.argv) |
Oops, something went wrong.