Skip to content

Commit

Permalink
fix: use typescripts
Browse files Browse the repository at this point in the history
  • Loading branch information
luthfimasruri committed Mar 29, 2021
1 parent ece8796 commit ca79061
Show file tree
Hide file tree
Showing 14 changed files with 544 additions and 613 deletions.
120 changes: 0 additions & 120 deletions scripts/bootstrap.js

This file was deleted.

121 changes: 121 additions & 0 deletions scripts/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// create package.json, README, etc. for packages that don't have them yet
(() => {
const fs = require('fs')
const path = require('path')

const args = require('minimist')(process.argv.slice(2))
const version: string = require('../package.json').version
const packagesDir: string = path.resolve(__dirname, '../packages')
const files: string[] = fs.readdirSync(packagesDir)

files.forEach((shortName) => {
if (!fs.statSync(path.join(packagesDir, shortName)).isDirectory()) {
return
}

const name = `@vueup/${shortName}`
const pkgPath = path.join(packagesDir, shortName, `package.json`)
const pkgExists = fs.existsSync(pkgPath)
if (pkgExists) {
const pkg = require(pkgPath)
if (pkg.private) {
return
}
}

if (args.force || !pkgExists) {
const json = {
name,
version,
description: name,
main: 'index.js',
module: `dist/${shortName}.esm-bundler.js`,
files: [`index.js`, `dist`],
types: `dist/${shortName}.d.ts`,
repository: {
type: 'git',
url: 'git+https://github.com/vuejs/vue.git',
},
keywords: ['vue-quill'],
author: 'Ahmad Luthfi Masruri',
license: 'MIT',
bugs: {
url: 'https://github.com/vueup/vue-quill/issues',
},
homepage: `https://github.com/vueup/vue-quill/tree/dev/packages/${shortName}#readme`,
}
fs.writeFileSync(pkgPath, JSON.stringify(json, null, 2))
}

const readmePath = path.join(packagesDir, shortName, `README.md`)
if (args.force || !fs.existsSync(readmePath)) {
fs.writeFileSync(readmePath, `# ${name}`)
}

const apiExtractorConfigPath = path.join(
packagesDir,
shortName,
`api-extractor.json`
)
if (args.force || !fs.existsSync(apiExtractorConfigPath)) {
fs.writeFileSync(
apiExtractorConfigPath,
`
{
"extends": "../../api-extractor.json",
"mainEntryPointFilePath": "./dist/packages/<unscopedPackageName>/src/index.d.ts",
"dtsRollup": {
"publicTrimmedFilePath": "./dist/<unscopedPackageName>.d.ts"
}
}
`.trim()
)
}

const assetsConfigPath = path.join(
packagesDir,
shortName,
`assets.config.json`
)
if (args.force || !fs.existsSync(assetsConfigPath)) {
fs.writeFileSync(
assetsConfigPath,
`
{
"css": [
{
"input": "./src/assets/css/index.css",
"output": "./dist/${shortName}.css"
}
]
}
`.trim()
)
}

const srcDir = path.join(packagesDir, shortName, `src`)
const indexPath = path.join(packagesDir, shortName, `src/index.ts`)
if (args.force || !fs.existsSync(indexPath)) {
if (!fs.existsSync(srcDir)) {
fs.mkdirSync(srcDir)
}
fs.writeFileSync(indexPath, ``)
}

const nodeIndexPath = path.join(packagesDir, shortName, 'index.js')
if (args.force || !fs.existsSync(nodeIndexPath)) {
fs.writeFileSync(
nodeIndexPath,
`
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/${shortName}.cjs.prod.js')
} else {
module.exports = require('./dist/${shortName}.cjs.js')
}
`.trim() + '\n'
)
}
})
})()
116 changes: 0 additions & 116 deletions scripts/build-assets.js

This file was deleted.

0 comments on commit ca79061

Please sign in to comment.