Skip to content

Commit

Permalink
fix: handle cjs specifics
Browse files Browse the repository at this point in the history
  • Loading branch information
PopGoesTheWza committed May 11, 2021
1 parent c294fc9 commit 8063851
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 10 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -98,6 +98,7 @@
"@types/recursive-readdir": "^2.2.0",
"@types/tmp": "^0.2.0",
"@types/watch": "^1.0.1",
"@types/wtfnode": "^0.7.0",
"chai": "^4.3.4",
"coveralls": "^3.1.0",
"gts": "^3.1.0",
Expand Down
4 changes: 3 additions & 1 deletion src/commands/help.ts
@@ -1,4 +1,6 @@
import {outputHelp} from 'commander';
import commander from 'commander';

const {outputHelp} = commander;

/**
* Outputs the help command.
Expand Down
4 changes: 3 additions & 1 deletion src/commands/login.ts
@@ -1,7 +1,7 @@
/**
* Clasp command method bodies.
*/
import {readJsonSync} from 'fs-extra';
import fs from 'fs-extra';

import {enableAppsScriptAPI} from '../apiutils.js';
import {authorize, defaultScopes, getLoggedInEmail, scopeWebAppDeploy} from '../auth.js';
Expand All @@ -10,6 +10,8 @@ import {readManifest} from '../manifest.js';
import {ERROR, LOG} from '../messages.js';
import {checkIfOnlineOrDie, hasOauthClientSettings, safeIsOnline} from '../utils.js';

const {readJsonSync} = fs;

interface CommandOption {
readonly localhost?: boolean;
readonly creds?: string;
Expand Down
3 changes: 2 additions & 1 deletion src/commands/push.ts
@@ -1,4 +1,4 @@
import {readFileSync} from 'fs-extra';
import fs from 'fs-extra';
import multimatch from 'multimatch';
import normalizeNewline from 'normalize-newline';
import path from 'path';
Expand All @@ -17,6 +17,7 @@ import {checkIfOnlineOrDie, getProjectSettings, spinner} from '../utils.js';

import type {ProjectSettings} from '../dotfile';

const {readFileSync} = fs;
const {project} = Conf.get();

interface CommandOption {
Expand Down
5 changes: 3 additions & 2 deletions src/files.ts
Expand Up @@ -5,13 +5,13 @@ import path from 'path';
import pMap from 'p-map';
import recursive from 'recursive-readdir';
import ts2gas from 'ts2gas';
import {parseConfigFileTextToJson} from 'typescript';
import typescript from 'typescript';

import {loadAPICredentials, script} from './auth.js';
import {ClaspError} from './clasp-error.js';
import {Conf} from './conf.js';
import {FS_OPTIONS, PROJECT_MANIFEST_FILENAME} from './constants.js';
import {DOTFILE} from './dotfile';
import {DOTFILE} from './dotfile.js';
import {ERROR, LOG} from './messages.js';
import {
checkIfOnlineOrDie,
Expand All @@ -24,6 +24,7 @@ import {

import type {TranspileOptions} from 'typescript';

const {parseConfigFileTextToJson} = typescript;
const {project} = Conf.get();

// An Apps Script API File
Expand Down
8 changes: 6 additions & 2 deletions src/index.ts
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const why = require('wtfnode'); // should be your first require
import why from 'wtfnode'; // should be your first require

/**
* @license
Expand All @@ -25,7 +25,9 @@ const why = require('wtfnode'); // should be your first require

import commander from 'commander';
import loudRejection from 'loud-rejection';
import {dirname} from 'path';
import {readPackageUpSync} from 'read-pkg-up';
import {fileURLToPath} from 'url';

import {ClaspError} from './clasp-error.js';
import apis from './commands/apis.js';
Expand All @@ -52,6 +54,8 @@ import {Conf} from './conf.js';
import {PROJECT_NAME} from './constants.js';
import {spinner, stopSpinner} from './utils.js';

const __dirname = dirname(fileURLToPath(import.meta.url));

let beforeExit = () => {};

// instantiate the config singleton (and loads environment variables as a side effect)
Expand All @@ -60,7 +64,7 @@ const {auth, ignore, project} = Conf.get();
// Ensure any unhandled exception won't go unnoticed
loudRejection();

const manifest = readPackageUpSync({cwd: require.resolve('.')});
const manifest = readPackageUpSync({cwd: __dirname});
// CLI

/**
Expand Down
4 changes: 3 additions & 1 deletion src/inquirer.ts
@@ -1,12 +1,14 @@
import {script_v1 as scriptV1} from 'googleapis';
import {prompt, registerPrompt} from 'inquirer';
import inquirer from 'inquirer';
import autocomplete from 'inquirer-autocomplete-prompt-ipt';

import {SCRIPT_TYPES} from './apis.js';
import {LOG} from './messages.js';

import type {ReadonlyDeep} from 'type-fest';

const {prompt, registerPrompt} = inquirer;

registerPrompt('autocomplete', autocomplete);

export type functionNameSource = (
Expand Down
6 changes: 4 additions & 2 deletions test/test.ts
Expand Up @@ -2,8 +2,9 @@ import {expect} from 'chai';
import {spawnSync} from 'child_process';
import fs from 'fs-extra';
import {after, before, describe, it} from 'mocha';
import path from 'path';
import path, { dirname } from 'path';
import {readPackageUpSync} from 'read-pkg-up';
import { fileURLToPath } from 'url';

import {getAppsScriptFileName, getLocalFileType} from '../src/files.js';
import {ERROR, LOG} from '../src/messages.js';
Expand All @@ -12,7 +13,8 @@ import {getApiFileType, getDefaultProjectName, getWebApplicationURL, saveProject
import {CLASP, CLASP_PATHS, CLASP_USAGE, IS_PR, SCRIPT_ID} from './constants.js';
import {backupSettings, cleanup, restoreSettings, setup} from './functions.js';

const manifest = readPackageUpSync({cwd: require.resolve('../src')});
const __dirname = dirname(fileURLToPath(import.meta.url));
const manifest = readPackageUpSync({cwd: __dirname});

describe.skip('Test --help for each function', () => {
const expectHelp = (command: string, expected: string) => {
Expand Down

0 comments on commit 8063851

Please sign in to comment.