-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dan Selman <danscode@selman.org>
- Loading branch information
Showing
3 changed files
with
111 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env node | ||
|
||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const globPattern = process.argv[2]; | ||
|
||
const util = require('util'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const copyFilePromise = util.promisify(fs.copyFile); | ||
const glob = require('glob'); | ||
|
||
// eslint-disable-next-line require-jsdoc | ||
function copyFiles(files, destDir) { | ||
if (!fs.existsSync('coverage')) { | ||
fs.mkdirSync('coverage'); | ||
} | ||
return Promise.all(files.map(f => { | ||
return copyFilePromise(f.source, path.join(destDir, f.destination)); | ||
})); | ||
} | ||
|
||
const lcovs = glob.sync(globPattern).map((dir) => { | ||
const packageName = dir.split('/').pop(); | ||
return { | ||
source: path.join(dir, 'coverage/coverage-final.json'), | ||
destination: `${packageName}.json` | ||
}; | ||
}); | ||
|
||
// usage | ||
copyFiles(lcovs, 'coverage').then(() => { | ||
console.log('done'); | ||
}).catch(err => { | ||
console.log(err); | ||
}); |
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,29 @@ | ||
#!/usr/bin/env node | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const semver = require('semver'); | ||
const targetVersion = process.argv[2]; | ||
|
||
if (!semver.valid(targetVersion)) { | ||
console.error(`Error: the version "${targetVersion}" is invalid!`); | ||
process.exit(1); | ||
} | ||
|
||
const prerelease = semver.prerelease(targetVersion); | ||
const tag = prerelease ? 'unstable' : 'latest'; | ||
|
||
console.log(`::set-output name=tag::--tag=${tag}`); |
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,32 @@ | ||
#!/usr/bin/env node | ||
|
||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
const semver = require('semver'); | ||
const dayjs = require('dayjs'); | ||
const utc = require('dayjs/plugin/utc'); | ||
dayjs.extend(utc); | ||
|
||
const timestamp = dayjs.utc().format('YYYYMMDDHHmmss'); | ||
|
||
const rootDir = path.resolve('.'); | ||
const packageJson = path.resolve(rootDir, 'package.json'); | ||
const meta = require(packageJson); | ||
meta.version.replace(/-.*/, ''); | ||
const targetVersion = semver.inc(meta.version, 'patch') + '-' + timestamp; | ||
console.log(`::set-output name=stamp::${targetVersion}`); |