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

Asyncify without topmost interface #95

Merged
merged 64 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
8b03d4c
Beautification of apm-cli
Sep 15, 2023
8095925
Wrap printVersions
Sep 15, 2023
aa6b2e9
Promisify getPythonVersion
Sep 15, 2023
debca29
Promisify getPythonVersion
Sep 15, 2023
6058e8c
Wrapping all the command executions
Sep 16, 2023
fe3bf87
Better sort broken testfiles
Sep 17, 2023
b092ca5
Cleanup and promisification of the develop command
Sep 18, 2023
1baaa60
auth.js getToken asyncified
Sep 18, 2023
cf85347
Promisify ci.js
Sep 18, 2023
ccb5d3e
Promisification of clean.js
Sep 18, 2023
34d78f7
Promisification of config.js
Sep 18, 2023
689e8e6
Promisification of disable.js
Sep 18, 2023
2e25bb0
Promisification of docs.js
Sep 18, 2023
11b6f14
Promisification of enable.js
Sep 18, 2023
9823c21
Promisification of featured.js
Sep 18, 2023
a4e6d70
Promisification of fs.js
Sep 22, 2023
1093f4a
Promisify git.js
Sep 22, 2023
df0adba
Promisification of init.js pt.1
Sep 22, 2023
47f7dba
init.js pt2: make generateFromTemplate look a bit more sensible
Sep 22, 2023
6da61f5
Asyncification of link.js
Sep 22, 2023
34b00e9
Asyncification of links.js
Sep 22, 2023
8aea62a
Promisification of list.js
Sep 22, 2023
17a9ace
Asyncification and polishment of package-converter.js
Sep 22, 2023
1cb698b
Tiny refinement of packages.js
Sep 22, 2023
8082018
Promisification of publish.js
Sep 23, 2023
63ba42c
Promisification of search.js
Sep 23, 2023
aee88bb
Fix with auth.js
Sep 23, 2023
1f3eced
Make saveToken more synchronized
Sep 23, 2023
a6a5410
Promisify star.js
Sep 23, 2023
02d399c
Asyncification of stars.js
Sep 23, 2023
356b6ef
Promisification of test.js, fixing related test
Sep 24, 2023
c6de74f
Asyncification of TextMate theme conversion
Sep 24, 2023
f2306f7
Prettifying tree.js
Sep 24, 2023
325bf0a
Promisification of uninstall.js
Sep 24, 2023
dba0396
Asyncification of unlink.js
Sep 24, 2023
c016e26
Asyncification of unpublish.js
Sep 24, 2023
0ef6662
Promisification of unstar.js
Sep 25, 2023
8fc1243
Asyncification of view.js
Sep 25, 2023
9139db1
Promisification of rebuild.js
Sep 25, 2023
34c73ba
Promise-based rework of command.js
Sep 26, 2023
2cb92e5
Prettifying git.js
Sep 26, 2023
f598740
Promisification of apm.js
Sep 26, 2023
ae43a46
Asyncify and fix upgrade.js
Sep 27, 2023
f16576b
Rewrite use of `async` module to more Promise-based interface
Sep 27, 2023
9d75fed
Promisification of install.js
Sep 29, 2023
e8dd06f
install.js reimagination of installGitPackage
Sep 29, 2023
ede3fe9
FIxing installation tests.
Sep 29, 2023
4f3f7e3
asyncification of dedupe.js
Sep 29, 2023
92f7ae7
Asyncification of rebuild-module-cache.js
Sep 29, 2023
0aaac88
Eliminating all callbacks from ci.js
Sep 29, 2023
cfac2bf
Eliminating all callbacks from develop.js
Sep 29, 2023
0a3e5c2
Eliminating all callbacks from star.js
Sep 29, 2023
8ba5e83
Eliminating all callbacks from unstar.js
Sep 29, 2023
316d9fe
Eliminating all callbacks from upgrade.js
Sep 29, 2023
ae90d47
Promisification of request.js
Sep 29, 2023
8576053
Asyncification of getTokenOrLogin
Sep 29, 2023
5e8d109
Elimination of Q and (partial) asyncification of login.js
Sep 30, 2023
ba12df8
Fully rework login.js into async
Sep 30, 2023
71278ea
Fix --version flag
Oct 1, 2023
2ba286b
Eliminating the promiseBased setting of commands
Oct 1, 2023
0e865d2
Eliminating unnecessary Promise contructors in favor of async
Oct 1, 2023
72f929d
s/Atom/Pulsar/ on the go
2colours Oct 18, 2023
e35010a
s/Atom/Pulsar/ in install
2colours Oct 18, 2023
4d0b679
s/Atom/Pulsar/ in enable
2colours Oct 18, 2023
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
6 changes: 3 additions & 3 deletions spec/ci-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('apm ci', () => {
apm.run(['ci'], callback);
waitsFor('waiting for install to complete', 600000, () => callback.callCount > 0);
runs(() => {
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
const pjson0 = CSON.readFileSync(path.join('node_modules', 'test-module-with-dependencies', 'package.json'));
expect(pjson0.version).toBe('1.1.0');
const pjson1 = CSON.readFileSync(path.join('node_modules', 'test-module', 'package.json'));
Expand All @@ -78,12 +78,12 @@ describe('apm ci', () => {
apm.run(['install'], callback0);
waitsFor('waiting for install to complete', 600000, () => callback0.callCount > 0);
runs(() => {
expect(callback0.mostRecentCall.args[0]).toBeNull();
expect(callback0.mostRecentCall.args[0]).toBeUndefined();
apm.run(['ci'], callback1);
});
waitsFor('waiting for ci to complete', 600000, () => callback1.callCount > 0);
runs(() => {
expect(callback1.mostRecentCall.args[0]).toBeNull();
expect(callback1.mostRecentCall.args[0]).toBeUndefined();
expect(fs.existsSync(path.join(moduleDirectory, 'node_modules', 'native-module', 'build', 'Release', 'native.node'))).toBeTruthy();
});
});
Expand Down
13 changes: 5 additions & 8 deletions spec/develop-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const fs = require('fs-plus');
const temp = require('temp');
const apm = require('../src/apm-cli');
const Develop = require('../src/develop');

describe('apm develop', () => {
let linkedRepoPath, repoPath;
Expand All @@ -19,10 +20,7 @@ describe('apm develop', () => {

describe("when the package doesn't have a published repository url", () => {
it('logs an error', () => {
const Develop = require('../src/develop');
spyOn(Develop.prototype, 'getRepositoryUrl').andCallFake((packageName, callback) => {
callback('Here is the error');
});
spyOn(Develop.prototype, 'getRepositoryUrl').andCallFake(_packageName => Promise.reject('Here is the error'));
const callback = jasmine.createSpy('callback');
apm.run(['develop', 'fake-package'], callback);
waitsFor('waiting for develop to complete', () => callback.callCount === 1);
Expand All @@ -36,13 +34,12 @@ describe('apm develop', () => {

describe("when the repository hasn't been cloned", () => {
it('clones the repository to ATOM_REPOS_HOME and links it to ATOM_HOME/dev/packages', () => {
const Develop = require('../src/develop');
spyOn(Develop.prototype, 'getRepositoryUrl').andCallFake((packageName, callback) => {
spyOn(Develop.prototype, 'getRepositoryUrl').andCallFake(_packageName => {
const repoUrl = path.join(__dirname, 'fixtures', 'repo.git');
callback(null, repoUrl);
return Promise.resolve(repoUrl);
});
spyOn(Develop.prototype, 'installDependencies').andCallFake(function (packageDirectory, options) {
this.linkPackage(packageDirectory, options);
return this.linkPackage(packageDirectory, options);
});
const callback = jasmine.createSpy('callback');
apm.run(['develop', 'fake-package'], callback);
Expand Down
26 changes: 13 additions & 13 deletions spec/install-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('apm install', () => {
expect(fs.existsSync(existingTestModuleFile)).toBeFalsy();
expect(fs.existsSync(path.join(testModuleDirectory, 'index.js'))).toBeTruthy();
expect(fs.existsSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy();
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});

Expand All @@ -121,7 +121,7 @@ describe('apm install', () => {

runs(() => {
expect(JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json'))).version).toBe('1.1.0');
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});

Expand All @@ -136,7 +136,7 @@ describe('apm install', () => {

runs(() => {
expect(JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json'))).version).toBe('1.1.0');
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});

Expand Down Expand Up @@ -173,7 +173,7 @@ describe('apm install', () => {
expect(fs.existsSync(testModuleDirectory)).toBeTruthy();
expect(fs.existsSync(path.join(testModuleDirectory, 'index.js'))).toBeTruthy();
expect(fs.existsSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy();
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});
});
Expand All @@ -195,7 +195,7 @@ describe('apm install', () => {
expect(fs.existsSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy();
expect(fs.existsSync(path.join(testModule2Directory, 'index2.js'))).toBeTruthy();
expect(fs.existsSync(path.join(testModule2Directory, 'package.json'))).toBeTruthy();
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});

Expand Down Expand Up @@ -305,7 +305,7 @@ describe('apm install', () => {
expect(fs.existsSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy();
expect(fs.existsSync(path.join(testModule2Directory, 'index2.js'))).toBeTruthy();
expect(fs.existsSync(path.join(testModule2Directory, 'package.json'))).toBeTruthy();
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
});
});

Expand Down Expand Up @@ -424,18 +424,17 @@ describe('apm install', () => {
beforeEach(() => {
install = new Install();

const fakeCloneRepository = (url, ...args) => {
const callback = args[args.length - 1];
const fakeCloneRepository = async (url, ..._rest) => {
if (url !== urls[2]) {
callback(new Error('Failed to clone'));
throw new Error('Failed to clone');
}
};

spyOn(install, 'cloneNormalizedUrl').andCallFake(fakeCloneRepository);
});

it('tries cloning the next URL until one works', () => {
install.cloneFirstValidGitUrl(urls, {}, () => {});
it('tries cloning the next URL until one works', async () => {
await install.cloneFirstValidGitUrl(urls, {}, () => {});
expect(install.cloneNormalizedUrl.calls.length).toBe(3);
expect(install.cloneNormalizedUrl.argsForCall[0][0]).toBe(urls[0]);
expect(install.cloneNormalizedUrl.argsForCall[1][0]).toBe(urls[1]);
Expand Down Expand Up @@ -565,7 +564,7 @@ describe('apm install', () => {
});
});

describe('when installing a registred package and --json is specified', () => {
describe('when installing a registered package and --json is specified', () => {
beforeEach(() => {
const callback = jasmine.createSpy('callback');
apm.run(['install', 'test-module', 'test-module2', '--json'], callback);
Expand Down Expand Up @@ -609,7 +608,7 @@ describe('apm install', () => {

waitsFor('waiting for install to complete', 600000, () => callback.callCount === 1);
runs(() => {
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();

const testModuleDirectory = path.join(atomHome, 'packages', 'native-package');
expect(fs.existsSync(path.join(testModuleDirectory, 'index.js'))).toBeTruthy();
Expand All @@ -624,5 +623,6 @@ describe('apm install', () => {
});
});
});

});
});
2 changes: 1 addition & 1 deletion spec/spec-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ global.silenceOutput = (callThrough = false) => {
}
};

global.spyOnToken = () => spyOn(auth, 'getToken').andCallFake(callback => callback(null, 'token'));
global.spyOnToken = () => spyOn(auth, 'getToken').andCallFake(() => Promise.resolve('token'));
2 changes: 1 addition & 1 deletion spec/stars-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('apm stars', () => {

waitsFor('waiting for command to complete', () => callback.callCount > 0);
runs(() => {
expect(callback.mostRecentCall.args[0]).toBeNull();
expect(callback.mostRecentCall.args[0]).toBeUndefined();
expect(fs.existsSync(path.join(testModuleDirectory, 'index.js'))).toBeTruthy();
expect(fs.existsSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy();
});
Expand Down
1 change: 1 addition & 0 deletions spec/test-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('apm test', () => {
removeListener() {}
}); // no op
apm.run(['test'], callback);
waitsFor('waiting for command to complete', () => callback.callCount > 0);
};

describe('successfully', () => {
Expand Down
10 changes: 2 additions & 8 deletions spec/unpublish-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ describe('apm unpublish', () => {
describe('when the user accepts the default answer', () => {
it('does not unpublish the package', () => {
const callback = jasmine.createSpy('callback');
spyOn(Unpublish.prototype, 'prompt').andCallFake((...args) => {
const cb = args.pop();
cb('');
});
spyOn(Unpublish.prototype, 'prompt').andCallFake(_question => Promise.resolve(''));
spyOn(Unpublish.prototype, 'unpublishPackage');
apm.run(['unpublish', 'test-package'], callback);

Expand Down Expand Up @@ -129,10 +126,7 @@ describe('apm unpublish', () => {
describe('when the user accepts the default answer', () => {
it('does not unpublish the package', () => {
const callback = jasmine.createSpy('callback');
spyOn(Unpublish.prototype, 'prompt').andCallFake((...args) => {
const cb = args.pop();
cb('');
});
spyOn(Unpublish.prototype, 'prompt').andCallFake(_question => Promise.resolve(''));
spyOn(Unpublish.prototype, 'unpublishPackage');
apm.run(['unpublish', 'test-package'], callback);

Expand Down
Loading