-
Notifications
You must be signed in to change notification settings - Fork 19
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
1 parent
88fc62e
commit 80fade5
Showing
9 changed files
with
99 additions
and
50 deletions.
There are no files selected for viewing
File renamed without changes.
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,36 @@ | ||
import { crossSpawnGitAsync } from '@git-lazy/spawn'; | ||
import { opts } from './_config'; | ||
import { ITSArrayListMaybeReadonly, ITSValueOrArrayMaybeReadonly } from 'ts-type/lib/type/base'; | ||
import { ISpawnGitAsyncOptions } from '@git-lazy/spawn/lib/types'; | ||
|
||
export function lazyCommitFiles(files: ITSValueOrArrayMaybeReadonly<string>, commitMessage: string, config?: { | ||
addFlags?: ITSArrayListMaybeReadonly<string>, | ||
options?: ISpawnGitAsyncOptions, | ||
}) | ||
{ | ||
files = [files].flat(); | ||
config ??= {}; | ||
|
||
const options: ISpawnGitAsyncOptions = { | ||
...opts, | ||
...config.options, | ||
}; | ||
|
||
const addFlags = config.addFlags ?? []; | ||
|
||
return crossSpawnGitAsync('git', [ | ||
'add', | ||
...addFlags, | ||
...files, | ||
], options) | ||
.then(() => | ||
{ | ||
return crossSpawnGitAsync('git', [ | ||
'commit', | ||
'-m', | ||
commitMessage, | ||
...files, | ||
], options) | ||
}) | ||
; | ||
} |
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,13 @@ | ||
import fetch from 'cross-fetch'; | ||
import { Response } from 'node-fetch'; | ||
import { outputFile } from 'fs-extra'; | ||
|
||
export function downloadPlugin(link: string, output_file: string) | ||
{ | ||
return fetch(link) | ||
.then((res) => (res as any as Response).buffer()) | ||
.then(buf => | ||
{ | ||
return outputFile(output_file, buf) | ||
}) | ||
} |
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,13 @@ | ||
import Bluebird from 'bluebird'; | ||
import { resolve } from 'upath2'; | ||
import { __root } from '../../test/__root'; | ||
|
||
export function _lazyImport<T>(target: string, dir = __root): Bluebird<T> | ||
{ | ||
return Bluebird.resolve(import(resolve(dir, target))).then(m => m.default ?? m) | ||
} | ||
|
||
export function _lazyImportWithDelay<T>(target: string, dir = __root, delay?: number): Bluebird<T> | ||
{ | ||
return _lazyImport<T>(target, dir).delay(delay || 2000) | ||
} |
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 |
---|---|---|
@@ -1,15 +1,8 @@ | ||
import fetch from 'cross-fetch'; | ||
import { Response } from 'node-fetch'; | ||
import { outputFile } from 'fs-extra'; | ||
import { join } from 'upath2'; | ||
import { cli_logger } from '../lib/cli-progress'; | ||
import { __plugin_downloaded_dir } from '../lib/const'; | ||
import { __plugin_zh_cn_download, __plugin_zh_cn_id, __plugin_zh_cn_version } from '../lib/const/link-of-zh-cn'; | ||
import { downloadPlugin } from '../lib/util/download-plugin'; | ||
|
||
export default cli_logger(fetch(__plugin_zh_cn_download) | ||
.then((res) => (res as any as Response).buffer()) | ||
.then(buf => | ||
{ | ||
return outputFile(join(__plugin_downloaded_dir, 'zh.zip'), buf) | ||
}), `download Chinese (Simplified) Language Pack / 中文语言包\nid: ${__plugin_zh_cn_id}\nversion: ${__plugin_zh_cn_version}`) | ||
export default cli_logger(downloadPlugin(__plugin_zh_cn_download, join(__plugin_downloaded_dir, 'zh.zip')), `download Chinese (Simplified) Language Pack / 中文语言包\nid: ${__plugin_zh_cn_id}\nversion: ${__plugin_zh_cn_version}`) | ||
; |
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 |
---|---|---|
@@ -1,28 +1,29 @@ | ||
import { crossSpawnGitAsync } from '@git-lazy/spawn'; | ||
import { opts } from './_config'; | ||
import { lazyCommitFiles } from '../../lib/git/commit'; | ||
import { _lazyImportWithDelay } from '../../lib/util/import'; | ||
import Bluebird from 'bluebird'; | ||
|
||
const list = [ | ||
'./original-plugin', | ||
'./original-plugin-raw', | ||
'./plugin-dev-out', | ||
'./plugin-dev-raw', | ||
'./lib/static', | ||
'./test/__snapshots__', | ||
'./lib/const/link-of-zh-cn.ts', | ||
] as const; | ||
|
||
export default crossSpawnGitAsync('git', [ | ||
'add', | ||
'--all', | ||
...list, | ||
], opts) | ||
export default Bluebird.mapSeries([ | ||
'./commit-version-map.ts', | ||
'./commit-link-of-zh-cn.ts', | ||
] as const, lazyImport) | ||
.then(() => | ||
{ | ||
return crossSpawnGitAsync('git', [ | ||
'commit', | ||
'-m', | ||
'build(release): update build', | ||
...list, | ||
], opts) | ||
}) | ||
; | ||
const list = [ | ||
'./original-plugin', | ||
'./original-plugin-raw', | ||
'./plugin-dev-out', | ||
'./plugin-dev-raw', | ||
'./lib/static', | ||
'./test/__snapshots__', | ||
'./lib/const/link-of-zh-cn.ts', | ||
] as const; | ||
|
||
return lazyCommitFiles(list, 'build(release): update build', { | ||
addFlags: ['--all'], | ||
}) | ||
}); | ||
|
||
function lazyImport(target: string) | ||
{ | ||
return _lazyImportWithDelay(target, __dirname) | ||
} |
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,5 @@ | ||
import { lazyCommitFiles } from '../../lib/git/commit'; | ||
|
||
export default lazyCommitFiles('./lib/const/link-of-zh-cn.ts', 'build(cache): update link-of-zh-cn.ts') | ||
.catch(() => void 0) | ||
; |
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 |
---|---|---|
@@ -1,18 +1,5 @@ | ||
import { crossSpawnGitAsync } from '@git-lazy/spawn'; | ||
import { opts } from './_config'; | ||
import { lazyCommitFiles } from '../../lib/git/commit'; | ||
|
||
export default crossSpawnGitAsync('git', [ | ||
'add', | ||
'./lib/const/version-map.json', | ||
], opts) | ||
.then(() => | ||
{ | ||
return crossSpawnGitAsync('git', [ | ||
'commit', | ||
'-m', | ||
'build(cache): update version-map', | ||
'./lib/const/version-map.json', | ||
], opts) | ||
}) | ||
export default lazyCommitFiles('./lib/const/version-map.json', 'build(cache): update version-map') | ||
.catch(() => void 0) | ||
; |
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