Skip to content

Commit e11d10d

Browse files
committed
ESM
1 parent a8b15eb commit e11d10d

File tree

8 files changed

+18138
-745579
lines changed

8 files changed

+18138
-745579
lines changed

dist/index.js

Lines changed: 18110 additions & 745551 deletions
Large diffs are not rendered by default.

dist/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

dist/pull-google-sheets-to-json.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { google } = require('googleapis');
2-
const fs = require('fs');
3-
const path = require('path');
1+
import { google } from 'googleapis';
2+
import fs from 'fs';
3+
import path from 'path';
44

55
const processSheet = async (sheetName, rows, localizationRoot) => {
66
if (!rows || rows.length === 0) {
@@ -97,8 +97,8 @@ const fetchSheetData = async () => {
9797
console.log('Data successfully pulled and JSON files updated');
9898
};
9999

100-
if (require.main === module) {
100+
if (import.meta.url === `file://${process.argv[1]}`) {
101101
fetchSheetData();
102102
}
103103

104-
module.exports = { processSheet, fetchSheetData };
104+
export { processSheet, fetchSheetData };

dist/push-json-to-google-sheets.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { google } = require('googleapis');
2-
const fs = require('fs');
3-
const path = require('path');
1+
import { google } from 'googleapis';
2+
import fs from 'fs';
3+
import path from 'path';
44

55
const parseLocalizationFiles = (folderPath) => {
66
const files = fs.readdirSync(folderPath).filter(file => file.endsWith('.json'));
@@ -121,8 +121,8 @@ const main = async () => {
121121
console.log('Data successfully uploaded to Google Sheets');
122122
};
123123

124-
if (require.main === module) {
124+
if (import.meta.url === `file://${process.argv[1]}`) {
125125
main();
126126
}
127127

128-
module.exports = { processFolder, parseLocalizationFiles };
128+
export { processFolder, parseLocalizationFiles };

entrypoint.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
const core = require('@actions/core');
2-
const { execSync } = require('child_process');
3-
const fs = require('fs');
4-
const path = require('path');
5-
6-
// Import the scripts to ensure they are included in the bundle
7-
require('./scripts/push-json-to-google-sheets');
8-
require('./scripts/pull-google-sheets-to-json');
1+
import core from '@actions/core';
2+
import { execSync } from 'child_process';
3+
import fs from 'fs';
4+
import path from 'path';
95

106
// Get inputs
117
const action = core.getInput('action');

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "abp-localization-sync",
33
"version": "1.0.1",
44
"description": "GitHub Action to sync localization data with Google Sheets",
5+
"type": "module",
56
"main": "dist/index.js",
67
"dependencies": {
78
"@actions/core": "^1.11.1",

scripts/pull-google-sheets-to-json.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { google } = require('googleapis');
2-
const fs = require('fs');
3-
const path = require('path');
1+
import { google } from 'googleapis';
2+
import fs from 'fs';
3+
import path from 'path';
44

55
const processSheet = async (sheetName, rows, localizationRoot) => {
66
if (!rows || rows.length === 0) {
@@ -97,8 +97,8 @@ const fetchSheetData = async () => {
9797
console.log('Data successfully pulled and JSON files updated');
9898
};
9999

100-
if (require.main === module) {
100+
if (import.meta.url === `file://${process.argv[1]}`) {
101101
fetchSheetData();
102102
}
103103

104-
module.exports = { processSheet, fetchSheetData };
104+
export { processSheet, fetchSheetData };

scripts/push-json-to-google-sheets.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { google } = require('googleapis');
2-
const fs = require('fs');
3-
const path = require('path');
1+
import { google } from 'googleapis';
2+
import fs from 'fs';
3+
import path from 'path';
44

55
const parseLocalizationFiles = (folderPath) => {
66
const files = fs.readdirSync(folderPath).filter(file => file.endsWith('.json'));
@@ -121,8 +121,8 @@ const main = async () => {
121121
console.log('Data successfully uploaded to Google Sheets');
122122
};
123123

124-
if (require.main === module) {
124+
if (import.meta.url === `file://${process.argv[1]}`) {
125125
main();
126126
}
127127

128-
module.exports = { processFolder, parseLocalizationFiles };
128+
export { processFolder, parseLocalizationFiles };

0 commit comments

Comments
 (0)