Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// No idea why this typing fails!
// @ts-ignore
content: module.code || '',
// @ts-ignore
isBinary: module.isBinary,
}));
// TODO: What is a template really? Two different kinds of templates here, need to fix the types
// Talk to Ives and Bogdan
const newTemplate = (computeTemplate(parsed, modulesByPath) ||
'node') as TemplateType;
if (
newTemplate !== currentTemplate &&
templateDefinition.isServer ===
getTemplateDefinition(newTemplate).isServer
) {
state.editor.currentSandbox.template = newTemplate;
await effects.api.saveTemplate(
state.editor.currentSandbox.id,
newTemplate
);
}
}
} catch (e) {
// We don't want this to be blocking at all, it's low prio
if (process.env.NODE_ENV === 'development') {
console.error(e);
}
}
};
async function getApiData(contents: any, sandbox: Sandbox) {
const template = getTemplate(sandbox.template);
let apiData: Partial = {
files: [],
};
let packageJSON: any = {};
let nowJSON: any = {};
const projectPackage = contents.files['package.json'];
const nowFile = contents.files['now.json'];
if (projectPackage) {
const data = await projectPackage.async('text'); // eslint-disable-line no-await-in-loop
const parsed = JSON.parse(data);
packageJSON = parsed;
}
export async function deployToNetlify({ http, props, state }) {
const { file } = props;
state.set('deployment.netlifyLogs', null);
const userId = state.get('user.id');
const sandboxId = state.get('editor.currentId');
const sandbox = state.get(`editor.sandboxes.${sandboxId}`);
const template = getTemplate(sandbox.template);
const buildCommand = name => {
switch (name) {
case 'styleguidist':
return 'styleguide:build';
case 'nuxt':
return 'generate';
default:
return 'build';
}
};
const buildConfig = getNetlifyConfig(sandbox);
// command needs to be passed without the package manager name
const buildCommandFromConfig = (buildConfig.command || '')
.replace('npm run', '')
.replace('yarn ', '');
async deploy(file: string, sandbox: Sandbox): Promise {
const userId = _options.getUserId();
const template = getTemplate(sandbox.template);
const buildCommand = (name: string) => {
if (name === 'styleguidist') {
return 'styleguide:build';
}
if (name === 'nuxt') {
return 'generate';
}
return 'build';
};
const buildConfig = getNetlifyConfig(sandbox);
// command needs to be passed without the package manager name
const buildCommandFromConfig = (buildConfig.command || '')
.replace('npm run', '')
.replace('yarn ', '');
let id = '';
(template, privacy) => {
const templateDefinition = getTemplate(template);
return templateDefinition.isServer && privacy === 2;
}
),
const { currentSandbox } = store.editor;
if (!currentSandbox.owned) {
return [PROJECT_SUMMARY, CONFIGURATION];
}
const isCustomTemplate = !!currentSandbox.customTemplate;
const items = [
isCustomTemplate ? PROJECT_TEMPLATE : PROJECT,
FILES,
CONFIGURATION,
];
if (store.isLoggedIn && currentSandbox) {
const templateDef = getTemplate(currentSandbox.template);
if (templateDef.isServer) {
items.push(SERVER);
}
}
if (store.isLoggedIn && currentSandbox && !currentSandbox.git) {
items.push(GITHUB);
}
if (store.isLoggedIn) {
items.push(DEPLOYMENT);
}
if (store.isLoggedIn) {
items.push(LIVE);
}
const {
actions: {
deployment: { getNetlifyDeploys },
},
state: {
deployment: { deploying, netlifySite },
editor: { currentSandbox },
},
} = useOvermind();
const [isVisible, setVisible] = useState(false);
useEffect(() => {
getNetlifyDeploys();
}, [getNetlifyDeploys]);
const template = getTemplate(currentSandbox.template);
return (
template.netlify !== false && (
setVisible(show => !show)}
/>
{netlifySite && isVisible ? : null}
)
);
};
export function defaultOpenedModule(
sandbox: Sandbox,
parsedConfigurations: Object
) {
const templateDefinition = getDefinition(sandbox.template);
const resolve = resolveModuleWrapped(sandbox);
const module = templateDefinition
.getDefaultOpenedFiles(parsedConfigurations)
.map(p => resolve(p))
.find(m => m);
return module || sandbox.modules[0];
}
${props => getTemplateDefinition(props.template).color.clearer(0.3)};
export const SSEDownNotice: FunctionComponent = () => {
const {
state: {
editor: {
currentSandbox: { template },
},
server: { status },
},
} = useOvermind();
if (!getTemplate(template).isServer) {
return null;
}
if (status !== 'disconnected') {
return null;
}
return (