Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions cmd/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const output = outputter('changelog', {
module.exports = async function changelog(cmd) {
const ipc = global.Pear[global.Pear.constructor.IPC]
const { json, full, max = 10 } = cmd.flags
const isKey = cmd.args.link && plink.parse(cmd.args.link).drive.key !== null
const channel = isKey ? null : cmd.args.link
const link = isKey ? cmd.args.link : null
if (link && isKey === false) throw ERR_INVALID_INPUT('Link "' + link + '" is not a valid key')
const link = cmd.args.link || null
if (link && plink.parse(link).drive.key === null) {
throw ERR_INVALID_INPUT('Link "' + link + '" is not a valid key')
}
const nmax = +max
if (Number.isInteger(nmax) === false) {
throw ERR_INVALID_INPUT('Changelog maximum must be an integer')
Expand All @@ -35,7 +35,6 @@ module.exports = async function changelog(cmd) {
json,
ipc.info({
link,
channel,
changelog: { max: nmax, semver: cmd.flags.of, full },
cmdArgs: Bare.argv.slice(1)
}),
Expand Down
27 changes: 12 additions & 15 deletions cmd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,11 @@ module.exports = async (ipc, argv = Bare.argv.slice(1)) => {
'stage',
summary('Synchronize local changes to link'),
description`
Channel name must be specified on first stage,
in order to generate the initial key.
Stage local changes to a project link.

Outputs diff information and project link.
`,
arg('<channel|link>', 'Channel name or Pear link to stage'),
arg('<link>', 'Pear link to stage'),
arg('[dir]', 'Project directory path (default: .)'),
flag('--dry-run|-d', 'Execute a stage without writing'),
flag('--ignore <paths>', 'Comma-separated path ignore list'),
Expand All @@ -131,11 +130,11 @@ module.exports = async (ipc, argv = Bare.argv.slice(1)) => {
'seed',
summary('Seed or reseed a project'),
description`
Specify channel or link to seed a project.
Specify a link to seed a project.

Specify a remote link to reseed.
`,
arg('<channel|link>', 'Channel name or Pear link to seed'),
arg('<link>', 'Pear link to seed'),
arg('[dir]', 'Project directory path (default: .)'),
flag('--verbose|-v', 'Additional output'),
flag('--name <name>', 'Advanced. Override app name'),
Expand All @@ -152,7 +151,7 @@ module.exports = async (ipc, argv = Bare.argv.slice(1)) => {

The target can then be multi-signed against a production link

Use pear touch to initialize target link
Use pear touch to generate target link
`,
arg('<source-link>', 'Versioned source link'),
arg('<target-link>', 'Target link to sync to'),
Expand All @@ -170,7 +169,7 @@ module.exports = async (ipc, argv = Bare.argv.slice(1)) => {

Use this to indicate production release points.
`,
arg('<channel|link>', 'Channel name or Pear link to release'),
arg('<link>', 'Pear link to release'),
arg('[dir]', 'Project directory path (default: .)'),
flag('--checkout <n>', 'Set release checkout n is version length'),
flag('--json', 'Newline delimited JSON output'),
Expand All @@ -192,11 +191,11 @@ module.exports = async (ipc, argv = Bare.argv.slice(1)) => {
'info',
summary('View project information'),
description`
Supply a link or channel to view application information.
Supply a link to view application information.

Supply no argument to view platform information.
`,
arg('[link|channel]', 'Project to view info for'),
arg('[link]', 'Project to view info for'),
arg('[dir]', 'Project directory path (default: .)'),
flag('--changelog', 'View changelog only').hide(),
flag('--full-changelog', 'Full record of changes').hide(),
Expand Down Expand Up @@ -232,10 +231,8 @@ module.exports = async (ipc, argv = Bare.argv.slice(1)) => {

const touch = command(
'touch',
summary('Initialize project link'),
description`Create a project Pear link if it doesn't already exist`,
arg('[channel]', 'Channel name. Default: randomly generated'),
flag('--dir', 'Project dir-based deterministic touch'),
summary('Generate random project link'),
description`Create a new random Pear link`,
flag('--json', 'Newline delimited JSON output'),
commands.touch
)
Expand Down Expand Up @@ -278,11 +275,11 @@ module.exports = async (ipc, argv = Bare.argv.slice(1)) => {
'changelog',
summary('View project changelog'),
description`
Supply a link or channel to view application changelog
Supply a link to view application changelog

Shows Pear changelog by default
`,
arg('[link|channel]', 'Project to view changelog of'),
arg('[link]', 'Project to view changelog of'),
flag('--max|-m <n=10>', 'Maximum entries to show'),
flag('--of <semver=^*>', 'SemVer filter - default: latest major'),
flag('--full', 'Show entire changelog'),
Expand Down
12 changes: 6 additions & 6 deletions cmd/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { outputter } = require('pear-terminal')
const { permit, isTTY } = require('pear-terminal')
const os = require('bare-os')
const path = require('bare-path')
const { ERR_INVALID_INPUT } = require('pear-errors')

const keys = ({ content, discovery, project }) => `
keys hex
Expand All @@ -13,11 +14,10 @@ const keys = ({ content, discovery, project }) => `
content ${content}
`

const info = ({ channel, release, name, length, byteLength, blobs, fork }) => `
const info = ({ release, name, length, byteLength, blobs, fork }) => `
info value
----------------- -----------------
name ${name}
channel ${channel}
release ${release}
length ${length}
fork ${fork}
Expand Down Expand Up @@ -68,9 +68,10 @@ const output = outputter('info', {
module.exports = async function info(cmd) {
const ipc = global.Pear[global.Pear.constructor.IPC]
const { json, changelog, fullChangelog: full, metadata, key: showKey, manifest } = cmd.flags
const isKey = cmd.args.link && plink.parse(cmd.args.link).drive.key !== null
const channel = isKey ? null : cmd.args.link
const link = isKey ? cmd.args.link : null
const link = cmd.args.link || null
if (link && plink.parse(link).drive.key === null) {
throw ERR_INVALID_INPUT('A valid pear link must be specified.')
}
let dir = cmd.args.dir
if (dir && path.isAbsolute(dir) === false) dir = path.resolve(os.cwd(), dir)
if (!dir) dir = os.cwd()
Expand All @@ -79,7 +80,6 @@ module.exports = async function info(cmd) {
json,
ipc.info({
link,
channel,
showKey,
metadata,
changelog: full || changelog ? { full, max: 1 } : null,
Expand Down
16 changes: 6 additions & 10 deletions cmd/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ const { ERR_INVALID_INPUT } = require('pear-errors')
const plink = require('pear-link')

const output = outputter('release', {
releasing: ({ name, channel, link }) =>
`\n${ansi.pear} Releasing ${name} [ ${channel || link} ]\n`,
releasing: ({ name, link }) => `\n${ansi.pear} Releasing ${name} [ ${link} ]\n`,
'updating-to': ({ releaseLength, currentLength }) =>
`Current length is ${currentLength}\nSetting release to ${releaseLength}\n`,
released: ({ name, channel, length }) =>
`The ${name} app (${channel} channel) was successfully released.\nLatest length: ${length}\n`,
released: ({ name, link, length }) =>
`The ${name} app (${link}) was successfully released.\nLatest length: ${length}\n`,
error: ({ code, stack }) => `Releasing Error (code: ${code || 'none'}) ${stack}`,
final: ({ reason = 'Release complete\n', success = true } = {}) => ({
output: 'print',
Expand All @@ -23,11 +22,9 @@ const output = outputter('release', {
module.exports = async function release(cmd) {
const ipc = global.Pear[global.Pear.constructor.IPC]
const { checkout, name, json } = cmd.flags
const isKey = plink.parse(cmd.args.channel).drive.key !== null
const channel = isKey ? null : cmd.args.channel
const link = isKey ? cmd.args.channel : null
if (!channel && !link) {
throw ERR_INVALID_INPUT('A valid pear link or the channel name must be specified.')
const link = cmd.args.link
if (!link || plink.parse(link).drive.key === null) {
throw ERR_INVALID_INPUT('A valid pear link must be specified.')
}
let dir = cmd.args.dir || os.cwd()
if (isAbsolute(dir) === false) dir = resolve(os.cwd(), dir)
Expand All @@ -40,7 +37,6 @@ module.exports = async function release(cmd) {
ipc.release({
id,
name,
channel,
link,
checkout,
dir,
Expand Down
19 changes: 7 additions & 12 deletions cmd/seed.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use strict'
const os = require('bare-os')
const { readFile } = require('bare-fs/promises')
const { join } = require('bare-path')
const plink = require('pear-link')
const { ERR_INVALID_INPUT } = require('pear-errors')
const { outputter, ansi, permit, isTTY } = require('pear-terminal')

const output = outputter('seed', {
seeding: ({ key, name, channel }) =>
`\n${ansi.pear} Seeding: ${key || `${name} [ ${channel} ]`}\n ${ansi.dim('ctrl^c to stop & exit')}\n`,
seeding: ({ key, name }) =>
`\n${ansi.pear} Seeding: ${key || name}\n ${ansi.dim('ctrl^c to stop & exit')}\n`,
key: (info) => `---:\n pear://${info}\n...`,
'content-key': (info) => `Content core key (hex) :-\n\n ${info}\n`,
'meta-key': (info) => `Meta discovery key (hex) :-\n\n ${info}\n`,
Expand All @@ -28,22 +27,18 @@ module.exports = async function seed(cmd) {
const ipc = global.Pear[global.Pear.constructor.IPC]
const { json, verbose, ask } = cmd.flags
const { dir = os.cwd() } = cmd.args
const isKey = plink.parse(cmd.args.channel).drive.key !== null
const channel = isKey ? null : cmd.args.channel
const link = isKey ? cmd.args.channel : null
let { name } = cmd.flags
if (!name && !link) {
const pkg = JSON.parse(await readFile(join(dir, 'package.json')))
name = pkg.pear?.name || pkg.name
const link = cmd.args.link
if (!link || plink.parse(link).drive.key === null) {
throw ERR_INVALID_INPUT('A valid pear link must be specified.')
}
const { name } = cmd.flags
const id = Bare.pid

await output(
json,
ipc.seed({
id,
name,
channel,
link,
verbose,
dir,
Expand Down
21 changes: 10 additions & 11 deletions cmd/stage.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict'
const os = require('bare-os')
const { isAbsolute, resolve } = require('bare-path')
const { outputter, ansi } = require('pear-terminal')
const plink = require('pear-link')
const { ERR_INVALID_INPUT } = require('pear-errors')
const { outputter, ansi } = require('pear-terminal')
const { permit, isTTY, byteDiff } = require('pear-terminal')
const State = require('pear-state')
const Pre = require('../pre')
Expand All @@ -18,9 +18,9 @@ function hints(skips) {
}

const output = outputter('stage', {
staging: ({ name, channel, link, verlink, current, release }) => {
staging: ({ name, link, verlink, current, release }) => {
const rel = `Release: ${release > 0 ? release : release + ansi.bold(ansi.dim(' [UNRELEASED]'))}`
return `\n${ansi.pear} Staging ${name} into ${channel}\n\n[ ${ansi.dim(link)} ]\n${ansi.gray(ansi.dim(verlink))}\n\nCurrent: ${current}\n${rel}\n`
return `\n${ansi.pear} Staging ${name}\n\n[ ${ansi.dim(link)} ]\n${ansi.gray(ansi.dim(verlink))}\n\nCurrent: ${current}\n${rel}\n`
},
skipping: ({ reason }) => 'Skipping warmup (' + reason + ')',
dry: 'NOTE: This is a dry run, no changes will be persisted.\n',
Expand All @@ -44,9 +44,9 @@ const output = outputter('stage', {
return `Staging Error (code: ${err.code || 'none'}) ${err.stack}`
}
},
addendum: ({ version, release, channel, link, verlink }) => {
addendum: ({ version, release, link, verlink }) => {
const rel = `Release: ${release > 0 ? release : release + ansi.bold(ansi.dim(' [UNRELEASED]'))}`
return `${ansi.dim(ansi.bold('^'))}Latest: ${ansi.bold(version)}\n${rel}\n\nUse ${ansi.bold(`pear release ${channel}`)} to set release to latest\n\n${ansi.gray(ansi.dim(verlink))}\n[ ${ansi.dim(link)} ]\n`
return `${ansi.dim(ansi.bold('^'))}Latest: ${ansi.bold(version)}\n${rel}\n\nUse ${ansi.bold(`pear release ${link}`)} to set release to latest\n\n${ansi.gray(ansi.dim(verlink))}\n[ ${ansi.dim(link)} ]\n`
},
['byte-diff']: byteDiff,
preio({ from, output, index, fd }, { preio }) {
Expand Down Expand Up @@ -77,11 +77,11 @@ const output = outputter('stage', {
module.exports = async function stage(cmd) {
const ipc = global.Pear[global.Pear.constructor.IPC]
const { dryRun, bare, json, ignore, purge, name, truncate, only, compact } = cmd.flags
const isKey = cmd.args.channel && plink.parse(cmd.args.channel).drive.key !== null
const channel = isKey ? null : cmd.args.channel
const key = isKey ? cmd.args.channel : null
if (!channel && !key) throw ERR_INVALID_INPUT('A key or the channel name must be specified')
const cwd = os.cwd()
const link = cmd.args.link
if (!link || plink.parse(link).drive.key === null) {
throw ERR_INVALID_INPUT('A valid pear link must be specified.')
}
let { dir = cwd } = cmd.args
if (isAbsolute(dir) === false) dir = dir ? resolve(os.cwd(), dir) : os.cwd()
const id = Bare.pid
Expand All @@ -100,8 +100,7 @@ module.exports = async function stage(cmd) {
}
const stream = ipc.stage({
id,
channel,
key,
link,
dir,
dryRun,
bare,
Expand Down
10 changes: 4 additions & 6 deletions cmd/touch.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'
const { outputter, ansi } = require('pear-terminal')
const { outputter } = require('pear-terminal')

const output = outputter('touch', {
final: ({ verlink, link, channel }) => {
final: ({ link }) => {
return {
output: 'print',
success: Infinity, // omit success ansi tick
message: `\n${ansi.dim(`[ channel: ${channel} ]`)}\n\n${ansi.gray(ansi.dim(verlink))}\n\n[ ${link} ]`
message: link
}
},
error: ({ message }) => {
Expand All @@ -16,8 +16,6 @@ const output = outputter('touch', {

module.exports = async function touch(cmd) {
const ipc = global.Pear[global.Pear.constructor.IPC]
const dir = cmd.args.dir
const json = cmd.flags.json
const channel = cmd.args.channel
await output(json, ipc.touch({ dir, channel }))
await output({ json, ctrlTTY: false, log: (line) => console.log(line) }, ipc.touch({}))
}
2 changes: 1 addition & 1 deletion examples/desktop/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Pear.teardown(async () => {
await new Promise((resolve) => setTimeout(resolve, 500)) // example async work
})

document.getElementById('channel').innerText = Pear.app.channel || 'none [ dev ]'
document.getElementById('link').innerText = Pear.app.link || 'none'
document.getElementById('release').innerText = Pear.app.release || (Pear.app.dev ? 'none [ dev ]' : '0')
const { app, platform } = await Pear.versions()
document.getElementById('platformKey').innerText = platform.key
Expand Down
6 changes: 3 additions & 3 deletions examples/desktop/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@
</table>
<table style="width:300px;">
<tr>
<th>Channel</th>
<td id="channel"></td>
<th>Link</th>
<td id="link"></td>
</tr>
<tr>
<th>Release</th>
Expand All @@ -121,4 +121,4 @@
</table>
<script src="./app.js" type="module"></script>
</body>
</html>
</html>
6 changes: 3 additions & 3 deletions subsystems/sidecar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,9 +952,9 @@ class Sidecar extends ReadyResource {
}
}

getCorestore(name, channel, opts) {
if (!name || !channel) return this.corestore.session({ writable: false, ...opts })
return this.corestore.namespace(`${name}~${channel}`, {
getCorestore(name, namespace, opts) {
if (!name || !namespace) return this.corestore.session({ writable: false, ...opts })
return this.corestore.namespace(`${name}~${namespace}`, {
writable: false,
...opts
})
Expand Down
Loading