flow(function*(groupName, groupId) { const { value: name } = yield prompt('Rename group', undefined, { inputValue: groupName }); if (name) { const group = self.groups.find(g => g.id === groupId); group.setName(name); } })
flow(function*() { const store = getRoot(self); yield self.runScript('install'); store.createNotification('Done', `Dependencies for ${self.name} are installed.`); })
flow(function*({ name, url }) { self.importingWebUrl.setFalse(); const newProject = Project.create({ name, webUrl: url, isWebBased: true }); self.projects.push(newProject); })
flow(function*(name) { const confirm = yield confirmDelete(); if (confirm) { const newPackageJson = { ...self.packageJson, scripts: omit(self.packageJson.scripts, name) }; self.updatePackageJson(newPackageJson); } })
flow(function*(name, version, isDev) { const packageJson = self.packageJson; const keys = isDev ? ['devDependencies', 'dependencies'] : ['dependencies', 'devDependencies']; const [moveFrom, moveTo] = keys; const newPackageJson = { ...packageJson, [moveFrom]: omit(packageJson[moveFrom], [name]), [moveTo]: { ...packageJson[moveTo], [name]: version } }; self.packageJson = newPackageJson; const pkgPath = path.join(self.path, 'package.json'); fs.writeFileSync(pkgPath, JSON.stringify(newPackageJson, null, 2)); })
flow(function*(projectId, projectName) { const project = self.projects.find(({ id }) => id === projectId); if (project === undefined) return; const { value: name } = yield prompt('Rename project', undefined, { inputValue: projectName }); if (name) { project.setName(name); } })
flow(function*() { const workspacePath = yield ipcc.callMain('open-dialog', { properties: ['openFile'], filters: [{ name: 'Custom File Type', extensions: ['code-workspace'] }] }); if (workspacePath) { self.importingWorkspace = JSON.parse(fs.readFileSync(workspacePath, 'utf8')); } })
flow(function*(formValues) { if (!formValues) { return null; } const { name, version, isDev = false } = formValues; if (name) { yield self.runScript('add', [`${name}${version ? `@${version}` : ''}`, isDev ? '--dev' : '--prod']); self.readProjectInfo(); } })
flow(function*(name) { const current = self.packageJson.favoriteScripts || []; const favoriteScripts = current.includes(name) ? current.filter(n => n !== name) : [...current, name]; const newPackageJson = { ...self.packageJson, favoriteScripts }; self.updatePackageJson(newPackageJson); })
flow(function*(projectId) { const confirmed = yield confirmDelete( 'Are you sure?', `This will only remove the project from the dashboard, it won't delete any files on disk.` ); if (confirmed) { self.projects = self.projects.filter(p => p.id !== projectId); } })
flow(function*() { const { value: name } = yield prompt('Group title'); if (name) { self.groups.push( Group.create({ name }) ); } })
flow(function*(gitRepo) { const result = yield axios.get('https://api.github.com/repos/kitze/jsui'); console.log('result, result', result); })
flow(function*(name) { const confirm = yield confirmDelete(); if (confirm) { yield self.runScript('remove', [name]); self.readProjectInfo(); } })
flow(function*() { const store = getRoot(self); store.setCloningProject(self); })
flow(function*(name) { self.runScript('upgrade', [`${name}@latest`]); })