-
Notifications
You must be signed in to change notification settings - Fork 1
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 #2 from databyss-org/paul/packaging
paul/packaging
- Loading branch information
Showing
7 changed files
with
1,130 additions
and
1,811 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Call-Em-All | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,65 @@ | ||
import path from 'path' | ||
import fse from 'fs-extra' | ||
|
||
async function copyFile(file) { | ||
const buildPath = path.resolve(__dirname, '../dist/', path.basename(file)) | ||
await fse.copy(file, buildPath) | ||
console.log(`Copied ${file} to ${buildPath}`) | ||
} | ||
|
||
async function createPackageFile() { | ||
const packageData = await fse.readFile( | ||
path.resolve(__dirname, '../package.json'), | ||
'utf8' | ||
) | ||
const { | ||
scripts, | ||
devDependencies, | ||
jest, | ||
babel, | ||
...packageDataOther | ||
} = JSON.parse(packageData) | ||
const newPackageData = { | ||
...packageDataOther, | ||
main: './index.js', | ||
module: './index.es.js', | ||
private: false, | ||
} | ||
const buildPath = path.resolve(__dirname, '../dist/package.json') | ||
|
||
await fse.writeFile( | ||
buildPath, | ||
JSON.stringify(newPackageData, null, 2), | ||
'utf8' | ||
) | ||
console.log(`Created package.json in ${buildPath}`) | ||
|
||
return newPackageData | ||
} | ||
|
||
async function prepend(file, string) { | ||
const data = await fse.readFile(file, 'utf8') | ||
await fse.writeFile(file, string + data, 'utf8') | ||
} | ||
|
||
async function addLicense(packageData) { | ||
const license = `/** @license databyss.org v${packageData.version} | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
` | ||
await Promise.all( | ||
['../dist/index.js', '../dist/index.es.js'].map(file => | ||
prepend(path.resolve(__dirname, file), license) | ||
) | ||
) | ||
} | ||
|
||
async function run() { | ||
await Promise.all(['./README.md', './LICENSE'].map(file => copyFile(file))) | ||
const packageData = await createPackageFile() | ||
await addLicense(packageData) | ||
} | ||
|
||
run() |
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,26 @@ | ||
// Do this as the first thing so that any code reading it knows the right env. | ||
process.env.BABEL_ENV = 'test' | ||
process.env.NODE_ENV = 'test' | ||
process.env.PUBLIC_URL = '' | ||
|
||
// Makes the script crash on unhandled rejections instead of silently | ||
// ignoring them. In the future, promise rejections that are not handled will | ||
// terminate the Node.js process with a non-zero exit code. | ||
process.on('unhandledRejection', err => { | ||
throw err | ||
}) | ||
|
||
const jest = require('jest') | ||
|
||
const argv = process.argv.slice(2) | ||
|
||
// Watch unless on CI or in coverage or debug mode | ||
if ( | ||
!process.env.CI && | ||
argv.indexOf('--coverage') < 0 && | ||
argv.indexOf('--debug') < 0 | ||
) { | ||
argv.push('--watchAll') | ||
} | ||
|
||
jest.run(argv) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.