Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(update): add node update and install functionality #328

Merged
merged 2 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/update.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use babel';

import { updates } from 'titanium-editor-commons';
import Utils from './utils';
import Project from './project';

import sudo from 'sudo-prompt';

const Update = {
Expand All @@ -11,7 +14,8 @@ const Update = {
this.checkingForUpdates = true;

try {
this.updates = await updates.checkAllUpdates();
const supportedVersions = await Utils.getNodeSupportedVersion(Project.sdk()[0]);
this.updates = await updates.checkAllUpdates({ nodeJS: supportedVersions });
} catch (error) {
// console.log(error);
}
Expand Down Expand Up @@ -45,7 +49,7 @@ const Update = {
});
if (error.metadata) {
const { metadata } = error;
if (update.productName === updates.ProductNames.AppcInstaller && metadata.errorCode === 'EACCES') {
if ((update.productName === updates.ProductNames.AppcInstaller || update.productName === updates.ProductNames.Node) && metadata.errorCode === 'EACCES') {
return new Promise((resolve, reject) => {
const errorNotification = atom.notifications.addError(`Failed to install ${label} as it must be ran with sudo`, {
dismissable: true,
Expand Down
16 changes: 15 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use babel';

import Appc from './appc';
import fs from 'fs';
import fs from 'fs-extra';
import path from 'path';
import semver from 'semver';
import _ from 'underscore';
Expand Down Expand Up @@ -298,5 +298,19 @@ export default {
} else {
return certificate.name;
}
},

async getNodeSupportedVersion(sdkVersion) {

const sdkInfo = Appc.sdkInfo(sdkVersion);
if (!sdkInfo) {
return;
}

const sdkPath = sdkInfo.path;

const packageJSON = path.join(sdkPath, 'package.json');
const { vendorDependencies } = await fs.readJSON(packageJSON);
return vendorDependencies.node;
}
};
101 changes: 62 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"engines": {
"atom": ">1.21.0"
},
"activationHooks": [
"core:loaded-shell-environment"
],
"keywords": [
"axway",
"appcelerator",
Expand Down Expand Up @@ -54,11 +57,12 @@
"dependencies": {
"etch": "^0.12.6",
"find": "^0.3.0",
"fs-extra": "^9.0.1",
"mkdirp": "^1.0.4",
"semver": "^7.3.2",
"sinon": "^9.0.3",
"sudo-prompt": "^9.2.1",
"titanium-editor-commons": "^0.5.1",
"titanium-editor-commons": "^1.0.2",
"underscore": "^1.11.0",
"xml2js": "^0.4.23"
},
Expand Down
13 changes: 12 additions & 1 deletion spec/controllerAutoCompleteProvider-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ describe('Ti namespace suggestions', function () {
this.timeout(5000);
sandbox = sinon.createSandbox();
atomEnvironment = global.buildAtomEnvironment();
await atomEnvironment.packages.triggerDeferredActivationHooks();
await atomEnvironment.packages.triggerActivationHook('core:loaded-shell-environment');
await atomEnvironment.packages.activatePackage(path.join(__dirname, '..'));
expect(atomEnvironment.packages.isPackageActive('appcelerator-titanium')).to.equal(true);
sandbox.stub(Project, 'sdk').resolves('8.1.0.GA');
sandbox.stub(tce.completion, 'loadCompletions').resolves(completions);
});
Expand Down Expand Up @@ -91,7 +94,10 @@ describe('Extended Ti suggestions', function () {
this.timeout(5000);
sandbox = sinon.createSandbox();
atomEnvironment = global.buildAtomEnvironment();
await atomEnvironment.packages.triggerDeferredActivationHooks();
await atomEnvironment.packages.triggerActivationHook('core:loaded-shell-environment');
await atomEnvironment.packages.activatePackage(path.join(__dirname, '..'));
expect(atomEnvironment.packages.isPackageActive('appcelerator-titanium')).to.equal(true);
sandbox.stub(Project, 'sdk').resolves('8.1.0.GA');
sandbox.stub(tce.completion, 'loadCompletions').resolves(completions);
});
Expand Down Expand Up @@ -139,7 +145,10 @@ describe('Alloy namespace suggestions', function () {
this.timeout(5000);
sandbox = sinon.createSandbox();
atomEnvironment = global.buildAtomEnvironment();
await atomEnvironment.packages.triggerDeferredActivationHooks();
await atomEnvironment.packages.triggerActivationHook('core:loaded-shell-environment');
await atomEnvironment.packages.activatePackage(path.join(__dirname, '..'));
expect(atomEnvironment.packages.isPackageActive('appcelerator-titanium')).to.equal(true);
sandbox.stub(Project, 'sdk').resolves('8.1.0.GA');
sandbox.stub(tce.completion, 'loadCompletions').resolves(completions);
});
Expand Down Expand Up @@ -172,7 +181,6 @@ describe('Alloy namespace suggestions', function () {
expect(suggestions[1].rightLabel).to.equal('Alloy');
expect(suggestions[1].snippet).to.equal('CFG');
expect(suggestions[1].priority).to.equal(2);
console.log(suggestions[2]);
expect(suggestions[2].type).to.equal('method');
expect(suggestions[2].displayText).to.equal('Alloy.Models');
} else {
Expand All @@ -197,7 +205,10 @@ describe('Extended Alloy suggestions', function () {
this.timeout(5000);
sandbox = sinon.createSandbox();
atomEnvironment = global.buildAtomEnvironment();
await atomEnvironment.packages.triggerDeferredActivationHooks();
await atomEnvironment.packages.triggerActivationHook('core:loaded-shell-environment');
await atomEnvironment.packages.activatePackage(path.join(__dirname, '..'));
expect(atomEnvironment.packages.isPackageActive('appcelerator-titanium')).to.equal(true);
sandbox.stub(Project, 'sdk').resolves('8.1.0.GA');
sandbox.stub(tce.completion, 'loadCompletions').resolves(completions);
});
Expand Down
6 changes: 6 additions & 0 deletions spec/styleAutoCompleteProvider-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ describe('Tag suggestions', function () {
this.timeout(5000);
sandbox = sinon.createSandbox();
atomEnvironment = global.buildAtomEnvironment();
await atomEnvironment.packages.triggerDeferredActivationHooks();
await atomEnvironment.packages.triggerActivationHook('core:loaded-shell-environment');
await atomEnvironment.packages.activatePackage(path.join(__dirname, '..'));
expect(atomEnvironment.packages.isPackageActive('appcelerator-titanium')).to.equal(true);
sandbox.stub(Project, 'sdk').resolves('8.1.0.GA');
sandbox.stub(tce.completion, 'loadCompletions').resolves(completions);
});
Expand Down Expand Up @@ -87,7 +90,10 @@ describe('Property suggestions', function () {
this.timeout(5000);
sandbox = sinon.createSandbox();
atomEnvironment = global.buildAtomEnvironment();
await atomEnvironment.packages.triggerDeferredActivationHooks();
await atomEnvironment.packages.triggerActivationHook('core:loaded-shell-environment');
await atomEnvironment.packages.activatePackage(path.join(__dirname, '..'));
expect(atomEnvironment.packages.isPackageActive('appcelerator-titanium')).to.equal(true);
sandbox.stub(Project, 'sdk').resolves('8.1.0.GA');
sandbox.stub(tce.completion, 'loadCompletions').resolves(completions);
});
Expand Down
6 changes: 6 additions & 0 deletions spec/viewAutoCompleteProvider-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ describe('Tag suggestions', function () {
this.timeout(5000);
sandbox = sinon.createSandbox();
atomEnvironment = global.buildAtomEnvironment();
await atomEnvironment.packages.triggerDeferredActivationHooks();
await atomEnvironment.packages.triggerActivationHook('core:loaded-shell-environment');
await atomEnvironment.packages.activatePackage(path.join(__dirname, '..'));
expect(atomEnvironment.packages.isPackageActive('appcelerator-titanium')).to.equal(true);
sandbox.stub(Project, 'sdk').resolves('8.1.0.GA');
});

Expand Down Expand Up @@ -89,7 +92,10 @@ describe('Attribute suggestions', function () {
this.timeout(5000);
sandbox = sinon.createSandbox();
atomEnvironment = global.buildAtomEnvironment();
await atomEnvironment.packages.triggerDeferredActivationHooks();
await atomEnvironment.packages.triggerActivationHook('core:loaded-shell-environment');
await atomEnvironment.packages.activatePackage(path.join(__dirname, '..'));
expect(atomEnvironment.packages.isPackageActive('appcelerator-titanium')).to.equal(true);
sandbox.stub(Project, 'sdk').resolves('8.1.0.GA');
sandbox.stub(tce.completion, 'loadCompletions').resolves(completions);
});
Expand Down