Skip to content

Commit

Permalink
feat!: publish in dual format (#497)
Browse files Browse the repository at this point in the history
* feat!: publish in dual format

* remove type files

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* Update ci.yaml

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* add missing dependencies

* add gapic-tools dep

* rfix tests, run lint and update jsdoc to json

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* rerun tests

* run lint

* omit certain files from synthtool

* force push tests

* rerun lint

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
sofisl and gcf-owl-bot[bot] authored Dec 11, 2024
1 parent 7ece46d commit a81bde8
Show file tree
Hide file tree
Showing 20 changed files with 335 additions and 145 deletions.
19 changes: 19 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"presets": [
"@babel/preset-typescript",
"@babel/env"
],
"plugins": [
[
"replace-import-extension",
{
"extMapping": {
".js": ".cjs"
}
}
],
"./node_modules/gapic-tools/build/src/replaceESMMockingLib.js",
"./node_modules/gapic-tools/build/src/replaceImportMetaUrl.js",
"./node_modules/gapic-tools/build/src/toggleESMFlagVariable.js"
]
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ docs/
protos/
samples/generated/
system-test/**/fixtures
*.d.ts
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ package-lock.json
__pycache__
.coverage
docs/
.DS_Store
.DS_Store
**/*.d.ts
*.d.ts
**/**.d.ts
51 changes: 0 additions & 51 deletions .jsdoc.js

This file was deleted.

34 changes: 34 additions & 0 deletions .jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"opts": {
"readme": "./README.md",
"package": "./package.json",
"template": "./node_modules/jsdoc-fresh",
"recurse": true,
"verbose": true,
"destination": "./docs/"
},
"plugins": [
"plugins/markdown",
"jsdoc-region-tag"
],
"source": {
"excludePattern": "(^|\\/|\\\\)[._]",
"include": [
"build/esm/src"
],
"includePattern": "\\.js$"
},
"templates": {
"copyright": "Copyright 2024 Google, LLC.",
"includeDate": false,
"sourceFiles": false,
"systemName": "gtoken",
"theme": "lumen",
"default": {
"outputSourceFiles": false
}
},
"markdown": {
"idInHeadings": true
}
}
29 changes: 29 additions & 0 deletions .mocharc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
const config = {
"enable-source-maps": true,
"throw-deprecation": true,
"timeout": 10000,
"recursive": true
}
if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
delete config['throw-deprecation'];
}
if (process.env.MOCHA_REPORTER) {
config.reporter = process.env.MOCHA_REPORTER;
}
if (process.env.MOCHA_REPORTER_OUTPUT) {
config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`;
}
module.exports = config
File renamed without changes.
5 changes: 1 addition & 4 deletions src/index.ts → esm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ export interface GetTokenOptions {
}

class ErrorWithCode extends Error {
constructor(
message: string,
public code: string,
) {
constructor(message: string, code: string) {

Check warning on line 67 in esm/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'code' is defined but never used
super(message);
}
}
Expand Down
2 changes: 1 addition & 1 deletion system-test/system.ts → esm/system-test/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import * as assert from 'assert';
import {describe, it} from 'mocha';
import {GoogleToken} from '../src';
import {GoogleToken} from '../src/index.js';
import {copyFileSync, readFileSync} from 'fs';

// gtoken requires a file extension to determine key type:
Expand Down
70 changes: 70 additions & 0 deletions esm/system-test/test.install.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import {describe, it} from 'mocha';
import {packNTest} from 'pack-n-play';

/**
* Optionally keep the staging directory between tests.
*/

describe('pack-n-play', () => {
it('supports ESM', async () => {
await packNTest({
sample: {
description: 'import as ESM',
esm: `
import {GoogleToken} from 'gtoken';
async function main() {
const gtoken = new GoogleToken();
}
main();
`,
},
});
});

it('supports CJS', async () => {
await packNTest({
sample: {
description: 'require as CJS',
cjs: `
const {GoogleToken} = require('gtoken');
async function main() {
const gtoken = new GoogleToken();
}
main();
`,
},
});
});

it('TypeScript', async function () {
this.timeout(300000);
await packNTest({
packageDir: process.cwd(),
sample: {
description: 'TypeScript user can use the type definitions',
ts: `
import {GoogleToken} from 'gtoken';
async function main() {
const gtoken = new GoogleToken();
}
main();
`,
},
});
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions esm/test/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Copyright 2018 Google LLC
*
* Distributed under MIT license.
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
export {};
Loading

0 comments on commit a81bde8

Please sign in to comment.