Skip to content

Commit

Permalink
initial version, with publish command
Browse files Browse the repository at this point in the history
  • Loading branch information
tomenden committed Mar 8, 2020
1 parent 44ae6a5 commit 9052aa6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
36 changes: 18 additions & 18 deletions packages/corvid-cli/src/commands/open-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ const { readCorvidConfig } = require("../utils/corvid-config");
const getMessage = require("../messages");
const { UserError } = require("corvid-local-logger");
const commandWithDefaults = require("../utils/commandWithDefaults");
const prompts = require('prompts');
const prompts = require("prompts");
const {
versions: { readFileSystemLayoutVersion }
} = require("corvid-local-site");


let userCommandIndex = 0
let userCommandIndex = 0;
const promptForCommand = async () => {
const response = await prompts({
type: "text",
message: "Type a command",
name: 'command'
})
const [cp] = getRunningProcesses()
cp.send({...response, i: userCommandIndex})
await new Promise((resolve) => {
name: "command"
});
const [cp] = getRunningProcesses();
cp.send({ ...response, i: userCommandIndex });
await new Promise(resolve => {
function listener(msg) {
const {result, i} = msg
const { result, i } = msg;
if (i === userCommandIndex) {
userCommandIndex++
cp.removeListener('message', listener)
resolve(result)
userCommandIndex++;
cp.removeListener("message", listener);
resolve(result);
}
}
cp.on('message', listener)
}).then(x => console.log(x))
await promptForCommand()
}
cp.on("message", listener);
// eslint-disable-next-line no-console
}).then(result => console.log(result));
await promptForCommand();
};

const ensureLocalFileSystemVersion = async siteRootPath => {
const existingFileSystemLayoutVersion = await readFileSystemLayoutVersion(
Expand Down Expand Up @@ -89,7 +89,7 @@ async function openEditorHandler(args) {
// background once the local server can be spawned in the background as
// well
//detached: true,
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
stdio: ["pipe", "pipe", "pipe", "ipc"],
cwd: siteDirectory,
env: {
...process.env,
Expand All @@ -109,7 +109,7 @@ async function openEditorHandler(args) {
spinner.succeed(
chalk.grey(getMessage("OpenEditor_Command_Connected"))
);
promptForCommand()
promptForCommand();
},
error: error => {
spinner.fail();
Expand Down
13 changes: 10 additions & 3 deletions packages/corvid-cli/src/utils/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function launch(file, options = {}, callbacks = {}, args = []) {

const cp = childProcess.spawn(
electron,
[path.resolve(path.join(file)), ...args, '--inspect-brk'],
[path.resolve(path.join(file)), ...args],
{
...options
}
Expand Down Expand Up @@ -177,12 +177,19 @@ async function openLocalEditorAndServer(app, windowOptions = {}) {
.executeJavaScript(
`
new Promise((resolve, reject) => {
rendered.props.store.getState().editorAPI.localMode.publish(resolve, reject)
rendered.props.store.getState().editorAPI.savePublish.save(false, 'CLI', {}).then(() => {
rendered.props.store.getState().editorAPI.localMode.publish(resolve, reject)
}).catch(reject)
})
`
)
.then(() => process.send({ i, result: "Publish sucess!" }))
.catch((e) => process.send({ i, result: `Publish failed :(\n Error: ${e} ` }));
.catch(e =>
process.send({
i,
result: `Publish failed :(\n Error: ${JSON.stringify(e)} `
})
);
}
// win.webContents.executeJavaScript(`console.log("${msg}")`)
});
Expand Down
1 change: 0 additions & 1 deletion packages/corvid-local-server/src/socket-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const initServerApi = (

const updateSiteDocument = withCloneModeNotification(
async updatedDocument => {
debugger
const result = await localSite.updateSiteDocument(updatedDocument);
notifyAdmin("document-updated");
wasSiteDocumentUpdated = true;
Expand Down
3 changes: 0 additions & 3 deletions packages/corvid-local-site/src/sitePaths.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ const removeSpaces = string => string.replace(/\s/g, "_");
const sanitizePageTitle = pageTitle => sanitize(removeSpaces(pageTitle));

const pageFilePath = ({ pageId, title, isPopup, extension, fileName }) => {
if (!title) {
debugger
}
const pageOrLightboxRoot = isPopup ? ROOT_PATHS.LIGHTBOXES : ROOT_PATHS.PAGES;
const sanitizedFolderTitle = sanitizePageTitle(title);
const sanitizedFilename = sanitizePageTitle(fileName || title);
Expand Down

0 comments on commit 9052aa6

Please sign in to comment.