format the source code

pull/405/head
Abdullah Alfaraj 2023-10-09 13:02:07 +03:00
parent 66ae39351f
commit 5f89d34568
8 changed files with 61 additions and 55 deletions

View File

@ -1,32 +1,33 @@
import chalk from 'chalk';
import { program } from 'commander';
import { createWriteStream, readFileSync, statSync, writeFileSync } from 'fs';
import { globSync } from 'glob';
import { dirname, join, relative } from 'path';
import { fileURLToPath } from 'url';
import chalk from 'chalk'
import { program } from 'commander'
import { createWriteStream, readFileSync, statSync, writeFileSync } from 'fs'
import { globSync } from 'glob'
import { dirname, join, relative } from 'path'
import { fileURLToPath } from 'url'
import yazl from 'yazl'
const __dirname = dirname(fileURLToPath(import.meta.url))
const basePath = join(__dirname, '..')
program
.requiredOption("--version <platform>", "the target platform")
.parse();
program.requiredOption('--version <platform>', 'the target platform').parse()
const version = program.opts().version;
if (!version.match(/\d+\.\d+\.\d+/)) throw new Error(`invalid version format: ${version}`);
const version = program.opts().version
if (!version.match(/\d+\.\d+\.\d+/))
throw new Error(`invalid version format: ${version}`)
console.log(chalk.cyan("rewriting manifest.json's version field to " + version));
const manifest = JSON.parse(readFileSync(`${basePath}/manifest.json`, 'utf-8'));
manifest.version = version;
writeFileSync(`${basePath}/manifest.json`, JSON.stringify(manifest));
console.log(chalk.cyan("rewriting manifest.json's version field to " + version))
const manifest = JSON.parse(readFileSync(`${basePath}/manifest.json`, 'utf-8'))
manifest.version = version
writeFileSync(`${basePath}/manifest.json`, JSON.stringify(manifest))
console.log(chalk.cyan("rewriting package.json's version field to " + version));
const packageJSON = JSON.parse(readFileSync(`${basePath}/package.json`, 'utf-8'));
packageJSON.version = version;
writeFileSync(`${basePath}/package.json`, JSON.stringify(packageJSON));
console.log(chalk.cyan("rewriting package.json's version field to " + version))
const packageJSON = JSON.parse(
readFileSync(`${basePath}/package.json`, 'utf-8')
)
packageJSON.version = version
writeFileSync(`${basePath}/package.json`, JSON.stringify(packageJSON))
console.log(chalk.cyan("packaging .ccx"));
console.log(chalk.cyan('packaging .ccx'))
const zipList = [
'./manifest.json',
'./i18n/**/*',
@ -46,24 +47,28 @@ const zipList = [
'./*.png',
]
const zipfile = new yazl.ZipFile();
const zipfile = new yazl.ZipFile()
zipList.forEach(globber => {
globSync(
join(basePath, globber).replace(/\\/g, '/')
).forEach(filepath => {
if (statSync(filepath).isDirectory()) return;
zipList.forEach((globber) => {
globSync(join(basePath, globber).replace(/\\/g, '/')).forEach(
(filepath) => {
if (statSync(filepath).isDirectory()) return
const rpath = relative(basePath, filepath);
zipfile.addFile(filepath, rpath)
})
const rpath = relative(basePath, filepath)
zipfile.addFile(filepath, rpath)
}
)
})
zipfile.outputStream.pipe(
createWriteStream(join(basePath, `Auto.Photoshop.SD.plugin_v${version}.ccx`))
);
createWriteStream(
join(basePath, `Auto.Photoshop.SD.plugin_v${version}.ccx`)
)
)
zipfile.outputStream.pipe(
createWriteStream(join(basePath, `Auto.Photoshop.SD.plugin_v${version}.zip`))
);
createWriteStream(
join(basePath, `Auto.Photoshop.SD.plugin_v${version}.zip`)
)
)
zipfile.end()
zipfile.end()

View File

@ -37,4 +37,4 @@
margin: 0;
padding: 0;
border: none;
}
}

View File

@ -39,7 +39,8 @@ async function requestControlNetApiVersion() {
async function requestControlNetMaxUnits() {
const json = await api.requestGet(`${g_sd_url}/controlnet/settings`)
const control_net_max_models_num = (json?.control_net_unit_count || json?.control_net_max_models_num) ?? 0
const control_net_max_models_num =
(json?.control_net_unit_count || json?.control_net_max_models_num) ?? 0
return control_net_max_models_num
}

View File

@ -259,7 +259,7 @@ export async function updateClickEventHandler(current_version: string) {
online_data.new_version
)
let header_message = "Your Plugin is up to date."
let header_message = 'Your Plugin is up to date.'
let long_message = ''
if (b_need_update) {
header_message = `New Version is Available (${online_data.new_version})`

View File

@ -5,16 +5,9 @@
}
.generateColor {
background-color: #ff595e;
}
.generateMoreColor {
background-color: #6db579;
}
}

View File

@ -1,4 +1,4 @@
/* styles.css */
#_tool_bar_container button:not(:last-child) {
margin-bottom: 3px;
}
}

View File

@ -251,7 +251,8 @@ export async function base64ToFileAndGetLayer(
_obj: 'rectangle',
bottom: {
_unit: 'pixelsUnit',
_value: jimp_image.bitmap.height * willScaleSize,
_value:
jimp_image.bitmap.height * willScaleSize,
},
left: {
_unit: 'pixelsUnit',
@ -274,7 +275,7 @@ export async function base64ToFileAndGetLayer(
commandName: 'select import area',
}
)
await executeAsModal(
async () => {
const result = await batchPlay(
@ -288,19 +289,25 @@ export async function base64ToFileAndGetLayer(
},
freeTransformCenterState: {
_enum: 'quadCenterState',
_value: "QCSCorner0"
_value: 'QCSCorner0',
},
offset: {
_obj: "offset",
horizontal: { _unit: "pixelsUnit", _value: 0.0 },
vertical: { _unit: "pixelsUnit", _value: 0.0 }
_obj: 'offset',
horizontal: { _unit: 'pixelsUnit', _value: 0.0 },
vertical: { _unit: 'pixelsUnit', _value: 0.0 },
},
_isCommand: true,
_options: {
dialogOptions: 'dontDisplay',
},
width: { "_unit": "percentUnit", "_value": 1 / willScaleSize * 100 },
height: { "_unit": "percentUnit", "_value": 1 / willScaleSize * 100 }
width: {
_unit: 'percentUnit',
_value: (1 / willScaleSize) * 100,
},
height: {
_unit: 'percentUnit',
_value: (1 / willScaleSize) * 100,
},
},
],
{}

View File

@ -3,4 +3,4 @@
border-right: 2px solid #3e3e3e;
margin: 0;
width: 100%;
}
}