Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit e4f302d

Browse files
committed
move demos out of main repo and into shell-composer-plugin repo
Fixes #1014
1 parent 8c22605 commit e4f302d

File tree

15 files changed

+42
-198
lines changed

15 files changed

+42
-198
lines changed

app/content/js/ui.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,6 +1821,8 @@ const ui = (function() {
18211821
* leading @ character?
18221822
*
18231823
*/
1824+
const specialPaths = [] // any special paths added via self.addPath
1825+
const defaultSpecial = { filepath: require('path').join(__dirname, '..') } // default special is the app/ top-level
18241826
self.findFile = (filepath, safe) => {
18251827
if (!filepath) {
18261828
if (!safe) {
@@ -1831,12 +1833,31 @@ const ui = (function() {
18311833
}
18321834
} else if (filepath.charAt(0) === '@') {
18331835
// ui.js is in the /app/build directory
1834-
return require('path').join(__dirname, '..', filepath.substring(1))
1836+
const desiredPrefix = require('path').dirname(filepath)
1837+
const special = specialPaths.find(({prefix}) => desiredPrefix.indexOf(prefix) === 0) || defaultSpecial
1838+
return require('path').join(special.filepath, filepath)
18351839
} else {
18361840
return require('expand-home-dir')(filepath)
18371841
}
18381842
}
18391843

1844+
/**
1845+
* Augment the module load path
1846+
*
1847+
*/
1848+
self.addPath = filepath => {
1849+
const path = require('path')
1850+
1851+
// use app-module-path to augment the node module require path
1852+
require('app-module-path').addPath(path.resolve(filepath))
1853+
1854+
// remember this for self.findFile
1855+
const prefix = path.basename(filepath)
1856+
if (prefix.charAt(0) === '@') {
1857+
specialPaths.push({ prefix , filepath: path.dirname(filepath) })
1858+
}
1859+
}
1860+
18401861
/**
18411862
* Get the userdata directory
18421863
*

app/demos/authenticate.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/demos/hello.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/demos/hello.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/demos/if.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

app/demos/let.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

app/demos/login.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/demos/retain.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

app/demos/try.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

app/demos/validate.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

app/demos/welcome.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"dependencies": {
3434
"about-window": "^1.11.0",
3535
"adm-zip": "^0.4.11",
36+
"app-module-path": "^2.2.0",
3637
"colors": "^1.3.0",
3738
"columnify": "^1.5.4",
3839
"debug": "^3.1.0",

app/plugins/modules/composer-preload/plugin.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@
1717
const debug = require('debug')('composer-preload')
1818
debug('loading')
1919

20+
const path = require('path')
2021

21-
module.exports = (commandTree, prequire) => {
22+
/**
23+
* Listen for drag and drop, and try to show a preview of the
24+
* composition on drop.
25+
*
26+
*/
27+
const listenForDrops = () => {
2228
if (typeof document !== 'undefined') {
2329
document.addEventListener('drop', event => {
2430
const { dataTransfer } = event,
@@ -35,3 +41,13 @@ module.exports = (commandTree, prequire) => {
3541
})
3642
}
3743
}
44+
45+
module.exports = (commandTree, prequire) => {
46+
// listen for drag and drop
47+
listenForDrops()
48+
49+
// give visibility to our @demos directory on the module path
50+
if (typeof document !== 'undefined') {
51+
ui.addPath(path.join(__dirname, '../composer/@demos'))
52+
}
53+
}

app/plugins/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"author": "",
1111
"license": "ISC",
1212
"dependencies": {
13-
"@shell/composer": "git://github.com/ibm-functions/shell-composer-plugin#0.5.2",
13+
"@shell/composer": "git://github.com/ibm-functions/shell-composer-plugin",
1414
"@shell/local": "git://github.com/ibm-functions/shell-local-plugin",
1515
"@shell/wskflow": "git://github.com/ibm-functions/shell-wskflow-plugin",
1616
"archiver": "^2.1.1",

tests/tests/passes/08/docs-introductory-scenario.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const common = require('../../../lib/common'),
5353
]
5454

5555
/** fetch source code for the app */
56-
const src = app => fs.readFileSync(path.join(__dirname, '../../../../app/demos/', `${app}.js`)).toString()
56+
const src = app => fs.readFileSync(path.join(__dirname, '../../../../app/plugins/modules/composer/@demos/', `${app}.js`)).toString()
5757

5858
// hardcode for now... we need to generate this every time
5959
const fsm = {

0 commit comments

Comments
 (0)