-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create a script for release (#147)
* chore: create a script for release * fix: creating multiple components * chore: update readme * fix: tests * fix: add custom button to react app
- Loading branch information
1 parent
dab39ef
commit 8960cf3
Showing
11 changed files
with
192 additions
and
37 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 |
---|---|---|
|
@@ -4,3 +4,4 @@ web-dev-server.config.js | |
tsup.config.ts | ||
**/test/** | ||
vite.config.ts | ||
scripts/prepare-packages.ts |
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
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
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
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,33 @@ | ||
import { beforeEach, describe, expect, it } from 'vitest'; | ||
import { DAppKitUI } from '../src'; | ||
import { waitFor } from '@testing-library/react'; | ||
|
||
describe('DAppKitModal', () => { | ||
beforeEach(() => { | ||
DAppKitUI.configure({ nodeUrl: 'https://mainnet.vechain.org/' }); | ||
}); | ||
|
||
it('should create an element', () => { | ||
const existing = document.querySelector('vwk-connect-modal'); | ||
|
||
expect(existing).toBe(null); | ||
|
||
DAppKitUI.modal.open(); | ||
|
||
waitFor(() => { | ||
const element = document.querySelector('vwk-connect-modal'); | ||
|
||
expect(element).not.toBe(null); | ||
expect(element?.open).toBe(true); | ||
}); | ||
|
||
DAppKitUI.modal.close(); | ||
|
||
waitFor(() => { | ||
const element = document.querySelector('vwk-connect-modal'); | ||
|
||
expect(element).not.toBe(null); | ||
expect(element?.open).toBe(false); | ||
}); | ||
}); | ||
}); |
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,88 @@ | ||
import util from 'util'; | ||
import * as child_process from 'child_process'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
const exec = util.promisify(child_process.exec); | ||
|
||
// variable packages should be all of the child folders in the packages folder | ||
const packages = fs.readdirSync(path.resolve(__dirname, '../packages')); | ||
|
||
console.log('packages', packages); | ||
|
||
const updatePackageVersions = (version: string) => { | ||
const packageNames = []; | ||
|
||
for (const pkg of packages) { | ||
const pkgPath = path.resolve(__dirname, `../packages/${pkg}`); | ||
const pkgJsonPath = path.resolve(pkgPath, './package.json'); | ||
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8')); | ||
pkgJson.version = version; | ||
packageNames.push(pkgJson.name); | ||
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2)); | ||
} | ||
|
||
// if a package json contains a dependency on another package in this repo, update it to the new version | ||
for (const pkg of packages) { | ||
const pkgPath = path.resolve(__dirname, `../packages/${pkg}`); | ||
const pkgJsonPath = path.resolve(pkgPath, './package.json'); | ||
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8')); | ||
|
||
for (const dep of Object.keys(pkgJson.dependencies)) { | ||
if (packageNames.includes(dep)) { | ||
pkgJson.dependencies[dep] = version; | ||
} | ||
} | ||
|
||
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2)); | ||
} | ||
}; | ||
|
||
const preparePackages = async () => { | ||
const version = process.argv[2]; | ||
|
||
if (!version || !version.match(/^\d+\.\d+\.\d+$/)) { | ||
console.error( | ||
`๐จ You must specify a semantic version as the first argument ๐จ`, | ||
); | ||
process.exit(1); | ||
} | ||
|
||
console.log('\n______________________________________________________\n\n'); | ||
console.log(` ๐๐๐ Preparing ${version} for release ๐๐๐`); | ||
console.log('\n______________________________________________________\n\n'); | ||
|
||
console.log(' Clean:'); | ||
console.log(' - ๐ฎ Removing existing packages & builds...'); | ||
await exec('yarn purge'); | ||
console.log(' - โ Removed!'); | ||
|
||
console.log(' Build:'); | ||
console.log(' - ๐ฆ Building packages...'); | ||
await exec('yarn install:all'); | ||
console.log(' - โ Built!'); | ||
|
||
console.log(' Test:'); | ||
console.log(' - ๐งช Testing packages...'); | ||
await exec('yarn test'); | ||
console.log(' - โ Success!'); | ||
|
||
console.log(' Version:'); | ||
console.log(` - ๐ท Updating package versions to ${version}...`); | ||
updatePackageVersions(version); | ||
await exec(`yarn format`); | ||
console.log(' - โ Updated!'); | ||
//log run `yarn changeset publish` to publish the packages | ||
|
||
console.log('\n______________________________________________________\n\n'); | ||
console.log(' Publish:'); | ||
console.log( | ||
` - Run 'yarn changeset publish' to publish the packages`, | ||
); | ||
console.log('\n______________________________________________________\n\n'); | ||
}; | ||
|
||
preparePackages().catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |