forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(quasar): add docsUrl to API definition (quasarframework#4045)
* quasar docs command * add docs * add sections * add sections to command * fix open browser * pass supplier to docs function * read quasar conf for open browser * fix command with app extensions API * open-browser using its own logger * fix Ripple docs * move "docs" defaults to build.api.js * fix DocApi trying to render docs field * fix QUploaderAddTrigger page * feat(api) change "docs" key to "meta" * fix(api) definitions for meta * fix(api) definitions for meta & `quasar docs` usage * feat(api) move docs opening to describe command and prefix API with "docs" * feat(docs) add new quasar describe option * fix(quasar) code review updates * fix(app) describe command
- Loading branch information
1 parent
d910893
commit eb3cb1e
Showing
4 changed files
with
142 additions
and
111 deletions.
There are no files selected for viewing
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
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
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,74 @@ | ||
const appPaths = require('../app-paths'), | ||
logger = require('./logger'), | ||
warn = logger('app:docs', 'red') | ||
|
||
module.exports = async function getApi(item) { | ||
try { | ||
const api = require( | ||
require.resolve(`quasar/dist/api/${item}.json`, { | ||
paths: [appPaths.appDir] | ||
}) | ||
) | ||
return { | ||
api | ||
} | ||
} catch (e) {} | ||
|
||
const extensionJson = require('../app-extension/extension-json') | ||
const extensions = Object.keys(extensionJson.getList()) | ||
|
||
if (extensions.length > 0) { | ||
const Extension = require('../app-extension/Extension.js') | ||
|
||
for (let ext of extensions) { | ||
const instance = new Extension(ext) | ||
const hooks = await instance.run({}) | ||
|
||
if (hooks.describeApi !== void 0 && hooks.describeApi[item]) { | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
let file | ||
const { | ||
callerPath, | ||
relativePath | ||
} = hooks.describeApi[item] | ||
|
||
if (relativePath.charAt(0) === '~') { | ||
try { | ||
file = relativePath.slice(1) | ||
file = require.resolve( | ||
file, { | ||
paths: [callerPath, appPaths.appDir] | ||
} | ||
) | ||
} catch (e) { | ||
warn(`⚠️ Extension(${instance.extId}): registerDescribeApi - there is no package "${file}" installed`) | ||
process.exit(1) | ||
} | ||
} else { | ||
file = path.resolve(callerPath, relativePath) | ||
|
||
if (!fs.existsSync(file)) { | ||
warn(`⚠️ Extension(${instance.extId}): registerDescribeApi - there is no file at ${file}`) | ||
process.exit(1) | ||
} | ||
} | ||
|
||
try { | ||
return { | ||
api: require(file), | ||
supplier: instance.extId | ||
} | ||
} catch (e) { | ||
warn(`⚠️ Extension(${instance.extId}): Malformed API file at ${file}`) | ||
process.exit(1) | ||
} | ||
} | ||
} | ||
} | ||
|
||
warn(`⚠️ No API found for requested "${item}"`) | ||
warn() | ||
process.exit(1) | ||
} |
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,35 @@ | ||
const logger = require('./logger'), | ||
log = logger('app:browser'), | ||
warn = logger('app:browser', 'red') | ||
|
||
module.exports = function openBrowser(url, opts) { | ||
const open = require('open') | ||
|
||
const openDefault = () => { | ||
log('Opening default browser at ' + url) | ||
log() | ||
open(url, { | ||
wait: true, | ||
url: true | ||
}).catch(() => { | ||
warn(`⚠️ Failed to open default browser`) | ||
warn() | ||
}) | ||
} | ||
|
||
if (opts) { | ||
log('Opening browser at ' + url + ' with options: ' + opts) | ||
log() | ||
open(url, { | ||
app: opts, | ||
wait: true, | ||
url: true | ||
}).catch(() => { | ||
warn(`⚠️ Failed to open specific browser`) | ||
warn() | ||
openDefault() | ||
}) | ||
} else { | ||
openDefault() | ||
} | ||
} |