Skip to content

Commit 9de356b

Browse files
committed
refactor: update prepublish issue
1 parent ae36197 commit 9de356b

4 files changed

Lines changed: 61 additions & 61 deletions

File tree

ast/postgresql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ export type with_clause = cte_definition[] | [cte_definition & {recursive: true;
465465

466466
export type cte_definition = { name: { type: 'default'; value: string; }; stmt: crud_stmt; columns?: cte_column_definition; };
467467

468-
export type cte_column_definition = column[];
468+
export type cte_column_definition = column_ref_list;
469469

470470
export type distinct_on = {type: string; columns: column_ref_list;} | { type: string | undefined; };
471471

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from '../types';
1+
export * from './types';

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"version": "4.4.0",
44
"description": "simple node sql parser",
55
"main": "index.js",
6-
"types": "types.d.ts",
6+
"types": "index.d.ts",
77
"scripts": {
88
"start": "webpack --config webpack.config.js",
9-
"build": "npm run lint && npm run compile && webpack --config webpack.config.js --prod",
9+
"build": "npm run lint && npm run compile && webpack --config webpack.config.js --mode production",
1010
"test": "npm run lint && mochapack \"test/**/*.spec.js\"",
1111
"lint": "eslint src",
1212
"compile": "babel src -d lib",
@@ -36,14 +36,14 @@
3636
"ast/",
3737
"build",
3838
"lib",
39-
"index.js",
39+
"umd/",
4040
"index.d.ts",
41+
"index.js",
4142
"index.js.map",
42-
"umd/",
43-
"README.md",
43+
"LICENSE",
4444
"package.json",
45-
"types.d.ts",
46-
"LICENSE"
45+
"README.md",
46+
"types.d.ts"
4747
],
4848
"license": "GPLv2",
4949
"bugs": {

webpack.config.js

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const webpack = require('webpack')
66
const nodeExternals = require('webpack-node-externals')
77

88
const isCoverage = process.env.NODE_ENV === 'coverage'
9-
const isProd = process.argv.includes('--prod')
10-
const isTest = isCoverage || process.argv.includes('--test')
9+
const isProd = process.argv.includes('production')
10+
const isTest = isCoverage || process.argv.includes('test')
1111
const subDir = isProd ? 'output/prod' : isTest ? 'output/test' : 'output/dev'
1212
const outputPath = path.join(__dirname, subDir)
1313
const srcPath = path.join(__dirname, 'src')
@@ -48,58 +48,58 @@ const getCopyFile = (database) => {
4848
]
4949
}
5050

51-
const getDbFile = () => ['bigquery', 'db2', 'hive', 'mariadb', 'mysql', 'sqlite', 'postgresql', 'transactsql', 'flinksql'].map(getCopyFile).reduce((prev, curr) => [...prev, ...curr], [])
52-
5351
const getSrcFile = () => fs.readdirSync(srcPath).filter(name => name !== 'parser.all.js' || name !== 'parser.single.js').map(name => ({ source: `${outputPath}/${name}`, destination: `${outputPath}/lib/${name}` }))
5452

55-
const getPlugins = (parserName, target, plugins) => [
56-
new webpack.DefinePlugin({
57-
PARSER_NAME: parserName ? JSON.stringify(parserName) : 'null',
58-
}),
59-
...(plugins || []),
60-
...(isProd
61-
? [
62-
new CopyPlugin({
63-
patterns: [
64-
'LICENSE',
65-
'lib',
66-
'README.md',
67-
'package.json',
68-
'types.d.ts',
69-
'ast/**',
70-
{
71-
from: 'index.d.ts',
72-
to: (parserName || 'index') + (target === 'web' ? '.umd' : '') + '.d.ts',
73-
}
74-
],
75-
}),
76-
new FileManagerPlugin({
77-
onEnd: {
78-
mkdir: [
79-
`${outputPath}/umd`,
80-
`${outputPath}/build`,
81-
`${outputPath}/lib`,
82-
],
83-
copy: [
84-
{ source: `${outputPath}/*.umd.d.ts`, destination: `${outputPath}/umd` },
85-
{ source: `${outputPath}/*.umd.js`, destination: `${outputPath}/umd` },
86-
{ source: `${outputPath}/*.umd.js.map`, destination: `${outputPath}/umd` },
87-
],
88-
move: [
89-
...getDbFile(),
90-
...getSrcFile(),
91-
],
92-
// delete: [
93-
// `${outputPath}/*.umd.d.ts`,
94-
// `${outputPath}/*.umd.js`,
95-
// `${outputPath}/*.umd.js.map`,
96-
// `${outputPath}/index.d.ts`
97-
// ]
98-
}
99-
})
100-
] : [
101-
])
102-
]
53+
const getPlugins = (parserName, target, plugins = []) => {
54+
const pluginList = [new webpack.DefinePlugin({ PARSER_NAME: parserName ? JSON.stringify(parserName) : 'null' }), ...plugins]
55+
if (isProd) {
56+
const tsFileName = (parserName || 'index') + (target === 'web' ? '.umd' : '') + '.d.ts'
57+
pluginList.push(
58+
new CopyPlugin({
59+
patterns: [
60+
'LICENSE',
61+
'lib',
62+
'README.md',
63+
'package.json',
64+
'types.d.ts',
65+
'ast/**',
66+
{
67+
from: 'index.d.ts',
68+
to: tsFileName,
69+
}
70+
],
71+
}),
72+
)
73+
const fileConfig = {
74+
events: { onEnd: {} },
75+
runTasksInSeries: true,
76+
}
77+
if (parserName === null) {
78+
if (target === 'web') {
79+
fileConfig.events.onEnd.mkdir = [
80+
`${outputPath}/umd`,
81+
`${outputPath}/build`,
82+
`${outputPath}/lib`,
83+
]
84+
fileConfig.events.onEnd.move = [
85+
{ source: `${outputPath}/index.umd.js`, destination: `${outputPath}/umd/index.umd.js` },
86+
{ source: `${outputPath}/index.umd.d.ts`, destination: `${outputPath}/umd/index.umd.d.ts` },
87+
{ source: `${outputPath}/index.umd.js.map`, destination: `${outputPath}/umd/index.umd.js.map` },
88+
]
89+
}
90+
if (target === 'node') fileConfig.events.onEnd.move = getSrcFile()
91+
} else {
92+
if (target === 'node') fileConfig.events.onEnd.move = getCopyFile(parserName)
93+
if (target === 'web') fileConfig.events.onEnd.move = [
94+
{ source: `${outputPath}/${parserName}.umd.d.ts`, destination: `${outputPath}/umd/${parserName}.umd.d.ts` },
95+
{ source: `${outputPath}/${parserName}.umd.js`, destination: `${outputPath}/umd/${parserName}.umd.js` },
96+
{ source: `${outputPath}/${parserName}.umd.js.map`, destination: `${outputPath}/umd/${parserName}.umd.js.map` },
97+
]
98+
}
99+
pluginList.push(new FileManagerPlugin(fileConfig))
100+
}
101+
return pluginList
102+
}
103103
const getOutput = (target) => ({
104104
path: outputPath,
105105
library: '',

0 commit comments

Comments
 (0)