diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/index.js b/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/index.js index 1ab0925453c..2bb45e98f6e 100644 --- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/index.js +++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/index.js @@ -24,7 +24,6 @@ import { class Deployment extends Component { componentDidMount = () => { this.props.signals.deployment.getDeploys(); - this.props.signals.deployment.getPeople(); }; render() { @@ -33,9 +32,6 @@ class Deployment extends Component { store: { user, deployment }, } = this.props; - const hasVoted = deployment.peopleWant2.find( - a => a.username === user.username - ); return (
@@ -50,50 +46,6 @@ class Deployment extends Component { {!user.integrations.zeit && ' You need to add ZEIT to your integrations to deploy.'} - - We currently only support Zeit v1. - {!hasVoted && deployment.peopleWant2.length ? ( - -
-
- If you would like us to support version 2.0 too please add your - thumbs up -
- ) : null} - -
{user.integrations.zeit ? ( diff --git a/packages/app/src/app/store/modules/deployment/actions.js b/packages/app/src/app/store/modules/deployment/actions.js index 963ccc039a8..c9fbf227188 100644 --- a/packages/app/src/app/store/modules/deployment/actions.js +++ b/packages/app/src/app/store/modules/deployment/actions.js @@ -13,61 +13,6 @@ export function loadZip({ props, jsZip }) { return jsZip.loadAsync(file).then(result => ({ contents: result })); } -export async function getPeopleWhoWant2() { - const Airtable = await import(/* webpackChunkName: 'airtable' */ '../../utils/setAirtable'); - - const base = await Airtable.default.base('apppgSmcJWwuXac6t'); - const params = base('zeit2').select({ - view: 'Grid view', - maxRecords: 100000, - }); - const people = []; - - const getPeople = () => - new Promise(res => { - params.eachPage( - (records, fetchNextPage) => { - records.forEach(record => { - people.push(record); - }); - fetchNextPage(); - }, - () => res() - ); - }); - - await getPeople(); - - return { - people: people.map(a => a.fields), - }; -} - -export async function addPersonWhoWant2({ path, props }) { - const Airtable = await import(/* webpackChunkName: 'airtable' */ '../../utils/setAirtable'); - - const base = await Airtable.default.base('apppgSmcJWwuXac6t'); - - const AddPerson = () => - new Promise((res, rej) => { - base('zeit2').create({ username: props.username }, err => { - if (err) { - console.error(err); - rej(); - } - res(); - }); - }); - - try { - await AddPerson(); - - return path.success(); - } catch (e) { - return path.error(); - } -} - export async function createApiData({ props, state }) { const { contents } = props; const sandboxId = state.get('editor.currentId'); @@ -101,13 +46,12 @@ export async function createApiData({ props, state }) { const nowDefaults = { name: `csb-${sandbox.id}`, - type: 'NPM', public: true, }; const filePaths = nowJSON.files || Object.keys(contents.files); - // We'll omit the homepage-value from package.json as it creates wrong assumptions over the now deployment evironment. + // We'll omit the homepage-value from package.json as it creates wrong assumptions over the now deployment environment. packageJSON = omit(packageJSON, 'homepage'); // We force the sandbox id, so ZEIT will always group the deployments to a @@ -117,8 +61,16 @@ export async function createApiData({ props, state }) { apiData.name = nowJSON.name || nowDefaults.name; apiData.deploymentType = nowJSON.type || nowDefaults.type; apiData.public = nowJSON.public || nowDefaults.public; - apiData.config = omit(nowJSON, ['public', 'type', 'name', 'files']); - apiData.forceNew = true; + + // if now v2 we need to tell now the version, builds and routes + if (nowJSON.version === 2) { + apiData.version = 2; + apiData.builds = nowJSON.builds; + apiData.routes = nowJSON.routes; + } else { + apiData.config = omit(nowJSON, ['public', 'type', 'name', 'files']); + apiData.forceNew = true; + } if (!nowJSON.files) { apiData.files.push({ @@ -138,7 +90,9 @@ export async function createApiData({ props, state }) { } } - if (template.alterDeploymentData) { + // this adds unnecessary code for version 2 + // packages/common/templates/template.js + if (template.alterDeploymentData && nowJSON.version !== 2) { apiData = template.alterDeploymentData(apiData); } @@ -167,10 +121,11 @@ export async function aliasDeployment({ http, path, props, state }) { export async function postToZeit({ http, path, props, state }) { const { apiData } = props; const token = state.get('user.integrations.zeit.token'); + const deploymentVersion = apiData.version === 2 ? 'v6' : 'v3'; try { const deployment = await http.request({ - url: 'https://api.zeit.co/v3/now/deployments', + url: `https://api.zeit.co/${deploymentVersion}/now/deployments?forceNew=1`, body: apiData, method: 'POST', headers: { Authorization: `bearer ${token}` }, diff --git a/packages/app/src/app/store/modules/deployment/index.js b/packages/app/src/app/store/modules/deployment/index.js index f599e708cc9..6aab3457ff2 100644 --- a/packages/app/src/app/store/modules/deployment/index.js +++ b/packages/app/src/app/store/modules/deployment/index.js @@ -5,7 +5,6 @@ import * as sequences from './sequences'; export default Module({ model, state: { - peopleWant2: [], hasAlias: false, deployToDelete: null, deploying: false, @@ -15,12 +14,10 @@ export default Module({ }, signals: { getDeploys: sequences.getDeploys, - addPersonFor2: sequences.addPersonFor2, deployClicked: sequences.deploy, deploySandboxClicked: sequences.openDeployModal, setDeploymentToDelete: sequences.deploymentToDelete, deleteDeployment: sequences.deleteDeployment, aliasDeployment: sequences.aliasDeployment, - getPeople: sequences.getPeopleWhoWant2, }, }); diff --git a/packages/app/src/app/store/modules/deployment/model.js b/packages/app/src/app/store/modules/deployment/model.js index 0c894f362a6..d892aa7f9e5 100644 --- a/packages/app/src/app/store/modules/deployment/model.js +++ b/packages/app/src/app/store/modules/deployment/model.js @@ -36,15 +36,10 @@ const Deploy = types.model('Deploy', { alias: types.maybeNull(types.array(Alias)), scale: types.maybeNull(Scale), creator: Creator, - type: types.enumeration('types', ['NPM', 'DOCKER', 'STATIC']), -}); - -const People = types.model('Person', { - username: types.maybeNull(types.string), + type: types.enumeration('types', ['NPM', 'DOCKER', 'STATIC', 'LAMBDAS']), }); export default { - peopleWant2: types.array(People), hasAlias: types.boolean, deployToDelete: types.maybeNull(types.string), deploying: types.boolean, diff --git a/packages/app/src/app/store/modules/deployment/sequences.js b/packages/app/src/app/store/modules/deployment/sequences.js index 1e80d58a0f5..a59b3dfb13d 100644 --- a/packages/app/src/app/store/modules/deployment/sequences.js +++ b/packages/app/src/app/store/modules/deployment/sequences.js @@ -14,30 +14,6 @@ export const deploymentToDelete = [ set(state`deployment.deployToDelete`, props`id`), ]; -export const getPeopleWhoWant2 = [ - actions.getPeopleWhoWant2, - set(state`deployment.peopleWant2`, props`people`), -]; - -export const addPersonFor2 = [ - actions.addPersonWhoWant2, - { - success: [ - actions.getPeopleWhoWant2, - set(state`deployment.peopleWant2`, props`people`), - addNotification('Your feedback has been saved', 'success'), - ], - error: [ - addNotification( - 'An unknown error occurred when adding your vote', - 'error' - ), - ], - }, - actions.getPeopleWhoWant2, - set(state`deployment.peopleWant2`, props`people`), -]; - export const getDeploys = [ actions.getDeploymentData, actions.getDeploymentData, diff --git a/packages/common/templates/configuration/now/index.js b/packages/common/templates/configuration/now/index.js index 921725f905d..d71e1b5b92d 100644 --- a/packages/common/templates/configuration/now/index.js +++ b/packages/common/templates/configuration/now/index.js @@ -7,14 +7,7 @@ const config: ConfigurationFile = { description: 'Configuration for your deployments on now.', moreInfoUrl: 'https://zeit.co/docs/features/configuration', - getDefaultCode: () => - JSON.stringify( - { - type: 'NPM', - }, - null, - 2 - ), + getDefaultCode: () => JSON.stringify({}, null, 2), }; export default config; diff --git a/packages/common/templates/template.js b/packages/common/templates/template.js index cb874c38428..b4de488b893 100644 --- a/packages/common/templates/template.js +++ b/packages/common/templates/template.js @@ -126,8 +126,8 @@ export default class Template { serve: '^10.1.1', }, scripts: { - ...parsedFile.scripts, 'now-start': `cd ${this.distDir} && serve -s ./`, + ...parsedFile.scripts, }, };