diff --git a/examples/bare/background/main.js b/examples/bare/background/main.js new file mode 100644 index 0000000..edcd10c --- /dev/null +++ b/examples/bare/background/main.js @@ -0,0 +1,5 @@ +const Wappsto = require('wappsto-wapp'); + +Wappsto.startLogging(); + +console.log('Background wapp started and stopped'); \ No newline at end of file diff --git a/examples/bare/background/package.json b/examples/bare/background/package.json new file mode 100644 index 0000000..858d51e --- /dev/null +++ b/examples/bare/background/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "wappsto-wapp": "*" + } +} diff --git a/examples/bare/foreground/index.html b/examples/bare/foreground/index.html new file mode 100644 index 0000000..13048f3 --- /dev/null +++ b/examples/bare/foreground/index.html @@ -0,0 +1,18 @@ + + + + + + + + Foreground Wapp + + + +

Foreground Wapp

+ + + + diff --git a/examples/background/main.js b/examples/simple/background/main.js similarity index 100% rename from examples/background/main.js rename to examples/simple/background/main.js diff --git a/examples/background/package.json b/examples/simple/background/package.json similarity index 100% rename from examples/background/package.json rename to examples/simple/background/package.json diff --git a/examples/foreground/index.html b/examples/simple/foreground/index.html similarity index 100% rename from examples/foreground/index.html rename to examples/simple/foreground/index.html diff --git a/examples/foreground/main.js b/examples/simple/foreground/main.js similarity index 100% rename from examples/foreground/main.js rename to examples/simple/foreground/main.js diff --git a/lib/wapp.js b/lib/wapp.js index fd8b19f..f1b8c12 100644 --- a/lib/wapp.js +++ b/lib/wapp.js @@ -208,8 +208,16 @@ class Wapp { dirs.concat(this.wapp_folders_create).forEach((f) => { const path = folderMapping[f] || f; files.createFolders(`${path}/.`); - if (createExamples && exampleFiles[f]) { - const exPath = `${__dirname}/../examples/${f}`; + + if (exampleFiles[f]) { + let exPath = `${__dirname}/../examples/`; + if (createExamples) { + exPath += 'simple'; + } else { + exPath += 'bare'; + } + exPath += `/${f}`; + exampleFiles[f].forEach((file) => { fs.copyFileSync(`${exPath}/${file}`, `${path}/${file}`); }); diff --git a/test/wapp.test.js b/test/wapp.test.js index d934d66..bc65dc3 100644 --- a/test/wapp.test.js +++ b/test/wapp.test.js @@ -93,7 +93,8 @@ test('create new empty wapp', async (t) => { t.deepEqual(files.fileExists('manifest.json'), true); t.deepEqual(files.directoryExists('foreground'), true); t.deepEqual(files.directoryExists('background'), false); - t.deepEqual(files.fileExists('foreground/index.html'), false); + t.deepEqual(files.fileExists('foreground/index.html'), true); + t.deepEqual(files.fileExists('foreground/main.js'), true); const manifest = files.loadJsonFile('manifest.json'); t.deepEqual(manifest.name, answer.name); @@ -107,6 +108,11 @@ test('create new empty wapp', async (t) => { test('update empty files', async (t) => { const wapp = new Wapp(); + if (files.directoryExists('foreground')) { + files.deleteFile('foreground/main.js'); + files.deleteFile('foreground/index.html'); + } + const updatedFiles = await wapp.update(); t.deepEqual(updatedFiles, []); }); @@ -418,7 +424,8 @@ test('create new custom wapp', async (t) => { t.deepEqual(files.directoryExists('customForeground'), true); t.deepEqual(files.directoryExists('customBackground'), false); t.deepEqual(files.directoryExists('background'), false); - t.deepEqual(files.fileExists('customForeground/index.html'), false); + t.deepEqual(files.fileExists('customForeground/index.html'), true); + t.deepEqual(files.fileExists('customForeground/main.js'), true); const manifest = files.loadJsonFile('manifest.json'); t.deepEqual(manifest.name, answer.name);