Skip to content

Commit

Permalink
fix: publish
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <danscode@selman.org>
  • Loading branch information
dselman committed Dec 12, 2023
1 parent 3664b9e commit e5c9551
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
50 changes: 50 additions & 0 deletions scripts/coverage.cjs
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);
});
29 changes: 29 additions & 0 deletions scripts/tag.cjs
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}`);
32 changes: 32 additions & 0 deletions scripts/timestamp.cjs
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}`);

0 comments on commit e5c9551

Please sign in to comment.