This repository has been archived by the owner on Jun 17, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
291 additions
and
5,786 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,64 @@ | ||
#!/bin/sh | ||
|
||
DIRECTORY="<%= dest.replace(/\/$/, "") %>" | ||
BRANCH="dist/frontend" | ||
CURRENT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') | ||
|
||
# Check if the environment is ready for publishing =========================== | ||
if [ "$CURRENT_BRANCH" != "master" ] | ||
then | ||
echo "⚠️ Please run this script from master branch" | ||
exit 1; | ||
fi | ||
|
||
if [[ $(git status -s) ]] | ||
then | ||
echo "⚠️ The working directory is dirty. Please commit any pending changes." | ||
exit 1; | ||
fi | ||
|
||
if [ $2 ] | ||
then | ||
npm whoami || { echo "⚠️ You must be logged in to NPM to push a new release" ; exit 1; } | ||
fi | ||
|
||
jq --version || { echo "⚠️ You have jq installed on your machine (brew install jq)" ; exit 1; } | ||
|
||
# Proceed ===================================================================== | ||
echo "rebuild frontend assets" | ||
yarn build | ||
|
||
echo "update package.json version to $1 and write a copy for publishing" | ||
npm version $1 | ||
cp package.json $DIRECTORY/package.json | ||
jq -e ".dependencies = {} | .devDependencies = {}" $DIRECTORY/package.json > $DIRECTORY/package.json.tmp && cp $DIRECTORY/package.json.tmp $DIRECTORY/package.json && rm $DIRECTORY/package.json.tmp | ||
|
||
echo "backup dist content" | ||
mkdir "$DIRECTORY-tmp" | ||
cp -r $DIRECTORY/* "$DIRECTORY-tmp/" | ||
|
||
echo "Deleting dist" | ||
rm -rf $DIRECTORY | ||
mkdir $DIRECTORY | ||
git worktree prune | ||
rm -rf .git/worktrees/$DIRECTORY/ | ||
|
||
echo "Checking out $BRANCH branch into dist" | ||
git worktree add -B $BRANCH $DIRECTORY | ||
|
||
echo "Removing existing files" | ||
rm -rf $DIRECTORY/* | ||
|
||
echo "Generating dist using the backup" | ||
cp -r "$DIRECTORY-tmp"/* $DIRECTORY/ | ||
rm -rf "$DIRECTORY-tmp" | ||
|
||
echo "Updating $BRANCH branch" | ||
if [ $2 ] | ||
then | ||
cd $DIRECTORY && git add --all && git commit -m "Publishing to $BRANCH (publish.sh)" | ||
git push --force origin $BRANCH --tags && npm publish | ||
else | ||
cd $DIRECTORY && git add --all && git commit -m "Publishing to $BRANCH (publish.sh)" | ||
git push --force origin $BRANCH --tags | ||
fi |
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,24 @@ | ||
const latestVersion = require('latest-version'); | ||
const chalk = require('chalk'); | ||
const pkg = require('./../package.json'); | ||
|
||
// Display update notification if it's not the last version | ||
module.exports = () => latestVersion('generator-toolbox').then(version => { | ||
try { | ||
if (version !== pkg.version) { | ||
const msg = ` Version ${version} (current ${pkg.version}) of generator-toolbox is available ! `; | ||
return ` | ||
${chalk.white.bgRed.bold(` ${' '.repeat(msg.length)} \n ${msg} \n${' '.repeat(msg.length)} `)} | ||
To update your beloved generator, do : | ||
$ ${chalk.green('yarn global upgrade generator-toolbox')} (recommended) | ||
or | ||
$ ${chalk.green('npm -g install generator-toolbox')} | ||
`; | ||
} | ||
return ''; | ||
} catch (error) { | ||
console.error('The NPM is unavailable to check for updates.'); | ||
return ''; | ||
} | ||
}); |
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,50 @@ | ||
'use strict'; | ||
const Generator = require('yeoman-generator'); | ||
const chalk = require('chalk'); | ||
const pathExists = require('path-exists'); | ||
const fs = require('fs'); | ||
|
||
const checkUpdate = require('../check-update'); | ||
|
||
module.exports = class extends Generator { | ||
constructor(args, opts) { | ||
super(args, opts); | ||
this.promptValues = this.config.getAll().promptValues; | ||
} | ||
|
||
async prompting() { | ||
await checkUpdate().then(res => this.log(res)); | ||
|
||
return this.prompt([{ | ||
type: 'list', | ||
name: 'tools', | ||
message: 'What kind of tool do you need', | ||
choices: [ | ||
{ | ||
name: `The ${chalk.yellow('publisher')} to create dist tagged branchs and to publish those dist to NPM`, | ||
value: 'publisher' | ||
} | ||
] | ||
}]).then(answers => { | ||
this.props = answers; | ||
}); | ||
} | ||
|
||
async writing() { | ||
switch (this.props.tools) { | ||
case 'publisher': | ||
this.fs.copyTpl( | ||
this.templatePath('_publish.sh'), | ||
this.destinationPath('publish.sh'), | ||
{ | ||
dest: this.promptValues.dest | ||
} | ||
); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
}; |
Oops, something went wrong.