Skip to content

Commit

Permalink
fix: try to fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
luthfimasruri committed Mar 29, 2021
1 parent ba5870d commit 6a4ea40
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 52 deletions.
2 changes: 1 addition & 1 deletion packages/vue-quill/src/assets/snow.styl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ backgroundColor = #fff
inactiveColor = #4B5563
shadowColor = #D1D5DB
textColor = #4B5563
// Additional colors
// Additional color
backgroundHoverColor = #F3F4F6
backgroundActiveColor = #DBEAFE

Expand Down
140 changes: 140 additions & 0 deletions scripts/preRelease.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
(async () => {
// const chalk = require('chalk')
// const execa = require('execa')
const path = require('path')
const semanticRelease = require('semantic-release')
// const { WritableStreamBuffer } = require('stream-buffers');
// const stdoutBuffer = WritableStreamBuffer();
// const stderrBuffer = WritableStreamBuffer();

const args = require('minimist')(process.argv.slice(2))
const target = args._[0]
const pkg = require(path.resolve(__dirname, `../packages/${target}`, 'package.json'))
const releaserc = {
branches: [
'master',
'next',
'next-major',
{ name: 'beta', prerelease: true },
{ name: 'alpha', prerelease: true }
],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
[
"@semantic-release/exec",
{
prepareCmd: "npx ts-node ../../scripts/build.ts --nextVersion ${nextRelease.version}"
}
],
'@semantic-release/npm',
[
'@semantic-release/github',
{
assets: [
{
path: `${target}-dist.zip`,
name: `${target}-dist-\$\{nextRelease.gitTag\}.zip`,
label: 'Distribution code (zip)'
}
]
}
]
]
}

await run()

async function run() {
// const nextVersion = await getNextVersion()
// console.log(nextVersion)
// await prepare(target)
await release()
}

// async function prepare(target: string/*, nextVersion: string*/) {
// try {
// // const buildScript = path.resolve(__dirname, 'build.ts')
// // console.log(chalk.bgCyan("Build package"))
// // execa.sync('npx', ['ts-node', buildScript, '--nextVersion', nextVersion])
// console.log(chalk.bgCyan("Zipping distribution file"))
// execa.sync('zip', ['-r', `${target}-dist.zip`, '.', '-i', 'dist'])
// } catch (err) {
// console.log(`>>>>>>>>>>>>> ${err}`)
// }
// }

async function release() {
const rootDir = path.resolve(__dirname, '..')
try {
console.log(`>>>>>>>>>>>>> Semantic release`)
const result = await semanticRelease({
// Core options
branches: releaserc.branches,
repositoryUrl: pkg.repository.url,
plugins: releaserc.plugins
}, {
// Run semantic-release from `/path/to/git/repo/root` without having to change local process `cwd` with `process.chdir()`
cwd: rootDir,
// Pass the variable `MY_ENV_VAR` to semantic-release without having to modify the local `process.env`
env: { ...process.env },
// Store stdout and stderr to use later instead of writing to `process.stdout` and `process.stderr`
// stdout: stdoutBuffer,
// stderr: stderrBuffer
});

if (result) {
console.log(`>>>>>>>>>>>>> Result`)
const { lastRelease, commits, nextRelease, releases } = result;

console.log(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`);

if (lastRelease.version) {
console.log(`The last release was "${lastRelease.version}".`);
}

for (const release of releases) {
console.log(`The release was published with plugin "${release.pluginName}".`);
}
} else {
console.log('No release published.');
}

// Get stdout and stderr content
// const logs = stdoutBuffer.getContentsAsString('utf8');
// const errors = stderrBuffer.getContentsAsString('utf8');
// console.log(logs, errors);

} catch (err) {
console.error('The automated release failed with %O', err)
}
}

// async function getNextVersion(): Promise<string> {
// try {
// const { nextRelease } = await semanticRelease({
// branches: releaserc.branches,
// repositoryUrl: pkg.repository.url,
// dryRun: true,
// ci: false,
// plugins: [
// '@semantic-release/commit-analyzer',
// [
// "@semantic-release/exec",
// {
// prepareCmd: "npx ts-node ../../scripts/build.ts --nextVersion ${nextRelease.version}"
// }
// ]
// ]
// }, {
// cwd: '../../',
// env: { ...process.env }
// })
// if (nextRelease) return nextRelease.version
// else console.log('No release will bepublished')
// } catch (err) {
// console.error('Failed to retrieve next version with %O', err)
// }
// return pkg.version
// }
})()
97 changes: 46 additions & 51 deletions scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(async () => {
// const chalk = require('chalk')
// const execa = require('execa')
const chalk = require('chalk')
const execa = require('execa')
const path = require('path')
const semanticRelease = require('semantic-release')
// const { WritableStreamBuffer } = require('stream-buffers');
Expand All @@ -21,12 +21,6 @@
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
[
"@semantic-release/exec",
{
prepareCmd: "npx ts-node ../../scripts/build.ts --nextVersion ${nextRelease.version}"
}
],
'@semantic-release/npm',
[
'@semantic-release/github',
Expand All @@ -46,26 +40,26 @@
await run()

async function run() {
// const nextVersion = await getNextVersion()
// console.log(nextVersion)
// await prepare(target)
const nextVersion = await getNextVersion()
console.log(nextVersion)
await prepare(target)
await release()
}

// async function prepare(target: string/*, nextVersion: string*/) {
// try {
// // const buildScript = path.resolve(__dirname, 'build.ts')
// // console.log(chalk.bgCyan("Build package"))
// // execa.sync('npx', ['ts-node', buildScript, '--nextVersion', nextVersion])
// console.log(chalk.bgCyan("Zipping distribution file"))
// execa.sync('zip', ['-r', `${target}-dist.zip`, '.', '-i', 'dist'])
// } catch (err) {
// console.log(`>>>>>>>>>>>>> ${err}`)
// }
// }
async function prepare(target: string/*, nextVersion: string*/) {
try {
// const buildScript = path.resolve(__dirname, 'build.ts')
// console.log(chalk.bgCyan("Build package"))
// execa.sync('npx', ['ts-node', buildScript, '--nextVersion', nextVersion])
console.log(chalk.bgCyan("Zipping distribution file"))
execa.sync('zip', ['-r', `${target}-dist.zip`, '.', '-i', 'dist'])
} catch (err) {
console.log(`>>>>>>>>>>>>> ${err}`)
}
}

async function release() {
const rootDir = path.resolve(__dirname, '..')
// const rootDir = path.resolve(__dirname, '..')
try {
console.log(`>>>>>>>>>>>>> Semantic release`)
const result = await semanticRelease({
Expand All @@ -75,7 +69,7 @@
plugins: releaserc.plugins
}, {
// Run semantic-release from `/path/to/git/repo/root` without having to change local process `cwd` with `process.chdir()`
cwd: rootDir,
// cwd: rootDir,
// Pass the variable `MY_ENV_VAR` to semantic-release without having to modify the local `process.env`
env: { ...process.env },
// Store stdout and stderr to use later instead of writing to `process.stdout` and `process.stderr`
Expand Down Expand Up @@ -110,31 +104,32 @@
}
}

// async function getNextVersion(): Promise<string> {
// try {
// const { nextRelease } = await semanticRelease({
// branches: releaserc.branches,
// repositoryUrl: pkg.repository.url,
// dryRun: true,
// ci: false,
// plugins: [
// '@semantic-release/commit-analyzer',
// [
// "@semantic-release/exec",
// {
// prepareCmd: "npx ts-node ../../scripts/build.ts --nextVersion ${nextRelease.version}"
// }
// ]
// ]
// }, {
// cwd: '../../',
// env: { ...process.env }
// })
// if (nextRelease) return nextRelease.version
// else console.log('No release will bepublished')
// } catch (err) {
// console.error('Failed to retrieve next version with %O', err)
// }
// return pkg.version
// }
async function getNextVersion(): Promise<string> {
const rootDir = path.resolve(__dirname, '..')
try {
const { nextRelease } = await semanticRelease({
branches: releaserc.branches,
repositoryUrl: pkg.repository.url,
// dryRun: true,
ci: false,
plugins: [
'@semantic-release/commit-analyzer',
[
"@semantic-release/exec",
{
prepareCmd: "npx ts-node scripts/build.ts --nextVersion ${nextRelease.version}"
}
]
]
}, {
cwd: rootDir,
env: { ...process.env }
})
if (nextRelease) return nextRelease.version
else console.log('No release will bepublished')
} catch (err) {
console.error('Failed to retrieve next version with %O', err)
}
return pkg.version
}
})()

0 comments on commit 6a4ea40

Please sign in to comment.