Skip to content

Commit

Permalink
Merge pull request #63 from ndaidong/3.0.4
Browse files Browse the repository at this point in the history
v3.0.4
  • Loading branch information
ndaidong authored Aug 20, 2022
2 parents f9814b2 + 4d96a9c commit dc23567
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 34 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ Lightweight util for generating random sentences, paragraphs and articles in Eng
![CodeQL](https://github.com/ndaidong/txtgen/workflows/CodeQL/badge.svg)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

[![Deploy](https://button.deta.dev/1/svg)](https://go.deta.dev/deploy?repo=https://github.com/ndaidong/txtgen-deta)

# Demo

[Want to see how it works?](https://ndaidong.github.io/txtgen/)

- [Want to see how it works?](https://ndaidong.github.io/txtgen/)
- [Deta service to generate text](https://txtgen.deta.dev/)

## Setup

Expand Down
13 changes: 2 additions & 11 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ execSync('rm -rf dist')
execSync('mkdir dist')

const buildTime = (new Date()).toISOString()
const longComment = [
'/**',
` * ${pkg.name}@${pkg.version}`,
` * built with esbuild at: ${buildTime}`,
` * repository: ${pkg.repository.url}`,
` * maintainer: ${pkg.author}`,
` * License: ${pkg.license}`,
'**/'
].join('\n')

const shortComment = [
`// ${pkg.name}@${pkg.version}, by ${pkg.author}`,
Expand All @@ -43,7 +34,7 @@ const esmVersion = {
mainFields: ['module'],
outfile: `dist/${pkg.name}.esm.js`,
banner: {
js: longComment
js: shortComment
}
}
buildSync(esmVersion)
Expand All @@ -55,7 +46,7 @@ const cjsVersion = {
mainFields: ['main'],
outfile: `dist/cjs/${pkg.name}.js`,
banner: {
js: longComment
js: shortComment
}
}
buildSync(cjsVersion)
Expand Down
42 changes: 42 additions & 0 deletions build.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// release.test

/* eslint-env jest */

import {
existsSync,
readFileSync
} from 'fs'

const pkg = JSON.parse(readFileSync('./package.json'))

const cjsFile = `./dist/cjs/${pkg.name}.js`
const cjsPkg = JSON.parse(readFileSync('./dist/cjs/package.json'))

const esmFile = `./dist/${pkg.name}.esm.js`
const minFile = `./dist/${pkg.name}.min.js`

describe('Validate commonjs version output', () => {
test(`Check if ${cjsFile} created`, () => {
expect(existsSync(cjsFile)).toBeTruthy()
})
test('Check if cjs package info updated', () => {
expect(cjsPkg.name).toEqual(`${pkg.name}-cjs`)
expect(cjsPkg.version).toEqual(pkg.version)
})
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()
})
})

describe('Check other built files', () => {
test(`Check if ${esmFile} created`, () => {
expect(existsSync(esmFile)).toBeTruthy()
})
test(`Check if ${minFile} created`, () => {
expect(existsSync(minFile)).toBeTruthy()
})
})
2 changes: 1 addition & 1 deletion dist/cjs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "txtgen-cjs",
"version": "3.0.3",
"version": "3.0.4",
"main": "./txtgen.js"
}
8 changes: 1 addition & 7 deletions dist/cjs/txtgen.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions dist/txtgen.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dc23567

Please sign in to comment.