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

Refactoring #778

Merged
merged 87 commits into from
Jun 5, 2020
Merged
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
83ae34e
chore: repo setup
PopGoesTheWza May 20, 2020
38a1f0c
style: refactor
PopGoesTheWza May 20, 2020
c31f133
fix:proper use of NodeJS.URL
PopGoesTheWza May 20, 2020
971d63e
fix: logic error
PopGoesTheWza May 20, 2020
7a720eb
ci: make `xo` linter prerequisite for tests
PopGoesTheWza May 20, 2020
4cbc57b
chore: stricter TS build config
PopGoesTheWza May 20, 2020
8ce7f07
chore: dead code cleanup
PopGoesTheWza May 20, 2020
56ed8c2
build: fixes some TS strict checks
PopGoesTheWza May 20, 2020
9870820
chore: switch to `gts` linter
PopGoesTheWza May 21, 2020
9c300c3
refactor: rename `tests` folder into `test`
PopGoesTheWza May 21, 2020
4e01f60
style: `gts` compliant
PopGoesTheWza May 21, 2020
9c1e599
fix: `bin` path
PopGoesTheWza May 21, 2020
4c6caae
chore: tentative ts-node fix
PopGoesTheWza May 21, 2020
6618d2d
chore: drop ts-node
PopGoesTheWza May 21, 2020
943a204
test: restore ts-node usage
PopGoesTheWza May 21, 2020
a561081
test: fix path to `build`
PopGoesTheWza May 21, 2020
8637455
test: fix path
PopGoesTheWza May 21, 2020
0bd25a4
test: fix reference issue
PopGoesTheWza May 21, 2020
a940d08
test: path cleanup
PopGoesTheWza May 21, 2020
5ec1ff8
style: linted
PopGoesTheWza May 22, 2020
76b3de2
chore: tweak `quotes` rules
PopGoesTheWza May 22, 2020
60e2605
chore: test setup
PopGoesTheWza May 22, 2020
118983b
chore: fix `check` command line
PopGoesTheWza May 22, 2020
8458bb8
chore: `nyc` config
PopGoesTheWza May 22, 2020
8e9d92f
chore: fix path to `package.json`
PopGoesTheWza May 22, 2020
c2dd8a8
chore: dependencies update
PopGoesTheWza May 22, 2020
17d33b5
refactor: loosening dependencies
PopGoesTheWza May 22, 2020
910519c
chore: obsolete setting
PopGoesTheWza May 22, 2020
572cc97
chore dependencies update
PopGoesTheWza May 22, 2020
e2947ab
refactor: replace `ellipsize`
PopGoesTheWza May 22, 2020
1d271cf
fix: typing of untyped modules
PopGoesTheWza May 22, 2020
53f73d1
chore: drop unnecessary config
PopGoesTheWza May 22, 2020
cb75128
style: tweak rules
PopGoesTheWza May 22, 2020
4af7051
style: eslint|tslint comments cleanup
PopGoesTheWza May 22, 2020
c23edb4
style: better typings
PopGoesTheWza May 22, 2020
ec2788f
refactoring: commander parseAsync
PopGoesTheWza May 22, 2020
f5720f5
refactor: drop `handleError()`
PopGoesTheWza May 22, 2020
8a329e4
refactor: drop unnecessary spinner code
PopGoesTheWza May 22, 2020
1e46f5b
refactor: add `getDescriptionFrom()` to use with `logError()`
PopGoesTheWza May 23, 2020
9897fad
style: typings
PopGoesTheWza May 23, 2020
e3c9960
chore: dependencies update
PopGoesTheWza May 23, 2020
8bfd0fe
refactor: commands throw errors instead of calling logError
PopGoesTheWza May 24, 2020
3f7f359
refactor: basic error management
PopGoesTheWza May 24, 2020
5f238d2
fix: import error
PopGoesTheWza May 24, 2020
65fa629
feat: introducing ClaspError
PopGoesTheWza May 24, 2020
9c4c68b
refactor: throw ClaspError
PopGoesTheWza May 24, 2020
64e5770
refactor: setupLogs
PopGoesTheWza May 24, 2020
3e745de
refactor: writeProjectFiles
PopGoesTheWza May 24, 2020
975b75b
refactor: getOAuthSettings & getProjectSettings
PopGoesTheWza May 24, 2020
9d65bdc
refactor: authorizeWithoutLocalhost
PopGoesTheWza May 24, 2020
3645865
refactor: promises into async/await
PopGoesTheWza May 24, 2020
043989b
feat: use loudRejection
PopGoesTheWza May 24, 2020
c1625ca
test: node 10 on windows
PopGoesTheWza May 24, 2020
51bf87a
ci: restore travis
PopGoesTheWza May 24, 2020
93a7e4b
ci: disable before_script
PopGoesTheWza May 24, 2020
f5b7262
style: eslint comments cleanup
PopGoesTheWza May 24, 2020
f85467a
feat: use readPkgUp to access package.json
PopGoesTheWza May 25, 2020
ae6a8fa
fix: squash some gremlins characters
PopGoesTheWza May 25, 2020
d74c2df
style: import autocomplete
PopGoesTheWza May 25, 2020
33d568c
style comment out dead code
PopGoesTheWza May 25, 2020
df1ebb4
style: TODO cleanup
PopGoesTheWza May 25, 2020
7fa5ae2
comment out more dead code
PopGoesTheWza May 25, 2020
245701a
test: fix '-v'
PopGoesTheWza May 25, 2020
77ea3e8
ci: temporarily test node 10 / windows
PopGoesTheWza May 25, 2020
ffa73fd
ci: fix EOL on windows
PopGoesTheWza May 25, 2020
e9a061a
style: comments
PopGoesTheWza May 25, 2020
d9539de
ci: focus on windows failing test
PopGoesTheWza May 25, 2020
bc28be9
ci: debug test
PopGoesTheWza May 25, 2020
cb1101b
ci: debug windows test
PopGoesTheWza May 25, 2020
02e6ccc
ci: check error type
PopGoesTheWza May 25, 2020
873d18d
ci: force exitCode
PopGoesTheWza May 25, 2020
ebd3215
ci: restore standard tests
PopGoesTheWza May 25, 2020
1388ff9
doc: PR #781
PopGoesTheWza May 25, 2020
be822d6
fix: silly typo
PopGoesTheWza May 25, 2020
3140a41
ci: try inquirer `isTtyError`
PopGoesTheWza May 25, 2020
4798fe8
ci: revert last commit
PopGoesTheWza May 25, 2020
cbd46e4
chore: add `gts` shield
PopGoesTheWza May 25, 2020
a90bde6
chore: fix `gts` globs
PopGoesTheWza May 25, 2020
0d0b93d
fix: peadPkgUp search path
PopGoesTheWza May 26, 2020
86ae03d
ci: fix test
PopGoesTheWza May 26, 2020
dbe1d98
test: cleaner require.resolve
PopGoesTheWza May 26, 2020
803e448
chore: update dependencies
PopGoesTheWza May 26, 2020
d11d3c7
chore: update tmp dev dependency
PopGoesTheWza May 27, 2020
e43034e
docs: typos and `gts`
PopGoesTheWza Jun 2, 2020
94e5f21
chore: update dependencies
PopGoesTheWza Jun 2, 2020
b36a2b4
chore: update dependencies
PopGoesTheWza Jun 5, 2020
5556452
style: drop xo, keep gts
PopGoesTheWza Jun 5, 2020
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
Prev Previous commit
Next Next commit
refactor: setupLogs
  • Loading branch information
PopGoesTheWza committed May 24, 2020
commit 64e5770107ce970837c643e0733a9be7c0c7cfc9
49 changes: 18 additions & 31 deletions src/commands/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {DOTFILE, ProjectSettings} from '../dotfile';
import {projectIdPrompt} from '../inquirer';
import {ERROR, LOG} from '../messages';
import {URL} from '../urls';
import {checkIfOnline, getDescriptionFrom, getProjectSettings, isValidProjectId, logError, spinner} from '../utils';
import {checkIfOnline, getErrorMessage, getProjectSettings, isValidProjectId, spinner} from '../utils';

interface CommandOption {
readonly json?: boolean;
Expand Down Expand Up @@ -144,36 +144,23 @@ function printLogs(

async function setupLogs(): Promise<string> {
let projectId: string;
return new Promise<string>((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises,promise/prefer-await-to-then
getProjectSettings().then((projectSettings: Readonly<ProjectSettings>) => {
console.log(`${LOG.OPEN_LINK(LOG.SCRIPT_LINK(projectSettings.scriptId))}\n`);
console.log(`${LOG.GET_PROJECT_ID_INSTRUCTIONS}\n`);
projectIdPrompt()
// eslint-disable-next-line promise/prefer-await-to-then
.then(answers => {
projectId = answers.projectId;
const dotfile = DOTFILE.PROJECT();
if (!dotfile) logError(ERROR.SETTINGS_DNE);
dotfile
.read<ProjectSettings>()
// eslint-disable-next-line promise/prefer-await-to-then
.then((settings: Readonly<ProjectSettings>) => {
if (!settings.scriptId) logError(ERROR.SCRIPT_ID_DNE);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
dotfile.write({...settings, ...{projectId}});
resolve(projectId);
})
.catch((error: object) => logError(getDescriptionFrom(error)));
})
.catch((error: Readonly<Error>) => {
console.log(error);
reject();
});
});
}).catch(error => {
throw new ClaspError(getDescriptionFrom(error) as string); // TODO get rid of type casting
});
try {
const projectSettings = await getProjectSettings();
console.log(`${LOG.OPEN_LINK(LOG.SCRIPT_LINK(projectSettings.scriptId))}\n`);
console.log(`${LOG.GET_PROJECT_ID_INSTRUCTIONS}\n`);
const answers = await projectIdPrompt();
projectId = answers.projectId;
const dotfile = DOTFILE.PROJECT();
if (!dotfile) throw new ClaspError(ERROR.SETTINGS_DNE);
const settings = await dotfile.read<ProjectSettings>();
if (!settings.scriptId) throw new ClaspError(ERROR.SCRIPT_ID_DNE);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
dotfile.write({...settings, ...{projectId}});
return projectId;
} catch (error) {
if (error instanceof ClaspError) throw error;
throw new ClaspError(getErrorMessage(error) as string); // TODO get rid of type casting
}
}

/**
Expand Down