Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
silent
} = detectEnv();
// build script
const script = buildCommand({
platform,
msvs_version,
debug,
runtime,
electronVersion: dependentElectronVersion
});
console.log(script);
// print build info
signale.info("Package Version =", packageVersion);
signale.info("Platform =", platform);
signale.info("Dependent Electron Version =", dependentElectronVersion);
signale.info("Build Runtime =", runtime, "\n");
// create two stream and start
signale.pending("Build C++ addon for Agora Electron SDK...\n");
const errLogWriteStream = fs.createWriteStream("error-log.txt", {
flags: "a"
});
const buildStream = shell.exec(
script,
{
silent: silent
},
(code, stdout, stderr) => {
if (code !== 0) {
rimraf(removeDir, err => {
if (err) {
signale.fatal(err);
process.exit(1);
}
// print download info
signale.info('Package Version =', packageVersion);
signale.info('Platform =', platform);
signale.info('Dependent Electron Version =', dependentElectronVersion);
signale.info('Download Url =', downloadUrl, '\n');
// start
signale.pending('Downloading prebuilt C++ addon for Agora Electron SDK...\n');
download(downloadUrl, outputDir, {
strip: 1,
extract: true
}).then(() => {
signale.success('Success', 'Download finished');
}).catch(err => {
signale.fatal('Failed', err);
});
});
};
async function main(): Promise {
const name = '@sourcegraph/code-host-integration'
// Bump version
let version: string
try {
const currentVersion = await latestVersion(name)
signale.info(`Current version is ${currentVersion}`)
version = semver.inc(currentVersion, 'patch')!
} catch (err) {
if (err && err.name === 'PackageNotFoundError') {
signale.info('Package is not released yet')
version = '0.0.0'
} else {
throw err
}
}
const packageJson = {
name,
version,
license: 'Apache-2.0',
repository: {
type: 'git',
url: 'https://github.com/sourcegraph/sourcegraph',
directory: 'browser',
},
}
signale.info(`New version is ${packageJson.version}`)
async updateFeeds(modification) {
let now = Date.now(),
prevDate = 0
this.modification = modification
if (this.siteObj.runtime && this.siteObj.runtime.feeds && this.siteObj.runtime.feeds.last_refresh > now - this.interval.recrawl) { // Still not needed to refresh
if (!this.siteObj.runtime.feeds.last_check || this.siteObj.runtime.feeds.last_check < now - this.interval.check) { // Add New feeds only
prevDate = this.siteObj.runtime.feeds.last_check // Save previous checking date for site database querying
signale.note(`Checking feeds for ${this.address}, date after ${prevDate}`)
modification.runtime.feeds.last_check = now
} else {
signale.note(`Stored feeds are up to date ${this.address}`)
return
}
} else {
signale.info(`Crawl all feeds for ${this.address}`)
await DataBase.clearFeeds(this.siteId) // Delete all outdated content
modification.runtime.feeds = { last_check: now, last_refresh: now }
}
for (let name in this.dbSchema.feeds)
if (name)
await this.pagingFeedQuery(this.dbSchema.feeds[name], name, 800, 0, prevDate ? (prevDate / 1000) : 0) // Convert prevDate to linux time
}
logger.error(e);
process.exit(1);
}
let action = new Action({
job: job,
run: params.run,
step: step,
secrets: params.secrets
});
try {
await axios.patch(`http://localhost:3000/steps/${step._id}`, {
status: "incomplete"
});
logger.info("Step started");
await action.execute();
logger.success("Step complete");
await axios.patch(`http://localhost:3000/steps/${step._id}`, {
status: "complete"
});
step.syslog.server.stop();
} catch (e) {
logger.error(`Failed to execute action`);
console.log(e);
}
});
}
'cjs | esm | umd',
)} is configured, checkout https://github.com/umijs/father for usage details.
`.trim(),
);
}
if (bundleOpts.entry) {
const tsConfigPath = join(cwd, 'tsconfig.json');
const tsConfig = existsSync(tsConfigPath)
|| (rootPath && existsSync(join(rootPath, 'tsconfig.json')));
if (
!tsConfig && (
(Array.isArray(bundleOpts.entry) && bundleOpts.entry.some(isTypescriptFile)) ||
(!Array.isArray(bundleOpts.entry) && isTypescriptFile(bundleOpts.entry))
)
) {
signale.info(
`Project using ${chalk.cyan('typescript')} but tsconfig.json not exists. Use default config.`
);
}
}
}
function log(msg) {
signale.info(`${pkg ? `[${pkg}] ` : ''}${msg}`);
}
async pagingQuery(count = 3000, start = 0, dateAfter = null) {
let rowsToAdd = []
signale.info(`Fetching optional files ${start}-${start + count} for ${this.address}`)
let rows = await ContentDB.getOptionalFiles(this.address, count, start, dateAfter)
if (!rows || rows.length === 0) {
signale.info(`No optional files found ${this.address}`)
return
}
for (let row of rows) {
let obj = {
inner_path: row.inner_path,
hash_id: row.hash_id,
size: row.size,
peer: row.peer,
time_added: row.time_added,
extra: {}
}
rowsToAdd.push(obj)
}
onMsg(e) {
try {
let cmd, message
message = JSON.parse(e.utf8Data)
cmd = message.cmd
if (cmd === "response" && this.waiting_cb[message.to] != null)
return this.waiting_cb[message.to](message.result)
else if (cmd === "ping")
this.response(message.id, "pong")
else
signale.info("Message from ZeroNet", message)
} catch (err) {
signale.error("Failed to parse message", err)
}
}
module.exports = (async function() {
const date = dateFns.format(new Date(), DATE_FORMAT)
log.info('Create new post:: ', date)
log.start('Start to process!\n')
const category = await fetchCategory()
const destDir = `${TARGET_DIR}/${category}`
const destDirExists = await fs.pathExists(destDir)
if (!destDirExists) {
await fs.ensureDir(destDir)
}
const title = await fetchTitle(category)
const fileName = getFileName(title)
const contents = refineContents({ title, date, category, draft: false })
fs.writeFile(`${destDir}/${fileName}.md`, contents, err => {
if (err) {