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

chore(deps): Update some dependencies, add Node 20 to CI #924

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [16.x, 18.x, 20.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -41,11 +41,23 @@ jobs:
node --version
npm --version

- uses: github/codeql-action/init@v3
with:
languages: javascript
queries: security-and-quality
config: |
paths-ignore:
- coverage
- node_modules
- spec/plugman/plugins/recursivePlug/demo

- name: npm install and test
run: npm cit
env:
CI: true

- uses: github/codeql-action/analyze@v3

- uses: codecov/codecov-action@v4
if: success()
with:
Expand Down
2 changes: 1 addition & 1 deletion cordova-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

const common = require('cordova-common');

exports = module.exports = {
module.exports = {
set binname (name) {
this.cordova.binname = name;
},
Expand Down
18 changes: 9 additions & 9 deletions integration-tests/HooksRunner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
under the License.
**/

const path = require('path');
const fs = require('fs-extra');
const delay = require('delay');
const fs = require('node:fs');
const path = require('node:path');
const timers = require('node:timers/promises');
const et = require('elementtree');

const HooksRunner = require('../src/hooks/HooksRunner');
Expand All @@ -39,11 +39,11 @@ describe('HooksRunner', function () {
project = path.join(tmp, 'project');

// Copy base project fixture
fs.copySync(path.join(fixtures, 'basePkgJson'), project);
fs.cpSync(path.join(fixtures, 'basePkgJson'), project, { recursive: true });

// Copy project hooks
const hooksDir = path.join(fixtures, 'projectHooks');
fs.copySync(hooksDir, path.join(project, 'scripts'));
fs.cpSync(hooksDir, path.join(project, 'scripts'), { recursive: true });

// Change into our project directory
process.chdir(project);
Expand All @@ -54,7 +54,7 @@ describe('HooksRunner', function () {

afterEach(() => {
process.chdir(path.join(__dirname, '..')); // Non e2e tests assume CWD is repo root.
fs.removeSync(tmp);
fs.rmSync(tmp, { recursive: true, force: true });
});

it('Test 001 : should throw if provided directory is not a cordova project', function () {
Expand All @@ -71,7 +71,7 @@ describe('HooksRunner', function () {

beforeEach(function () {
hooksOrderFile = path.join(project, 'hooks_order.txt');
fs.removeSync(hooksOrderFile);
fs.rmSync(hooksOrderFile, { recursive: true, force: true });
});

// helper methods
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('HooksRunner', function () {
beforeEach(() => {
// Add the test plugin to our project
testPluginInstalledPath = path.join(project, 'plugins', testPlugin);
fs.copySync(testPluginFixture, testPluginInstalledPath);
fs.cpSync(testPluginFixture, testPluginInstalledPath, { recursive: true });
});

function addHooksToPlugin (hooksXml) {
Expand Down Expand Up @@ -309,7 +309,7 @@ describe('HooksRunner', function () {
const order = [];
// Delay 100 ms here to check that h2 is not executed until after
// the promise returned by h1 is resolved.
const h1 = _ => delay(100).then(_ => order.push(1));
const h1 = _ => timers.setTimeout(100).then(_ => order.push(1));
const h2 = _ => Promise.resolve().then(_ => order.push(2));

cordova.on(test_event, h1);
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/fetch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
under the License.
*/

const path = require('path');
const fs = require('fs-extra');
const path = require('node:path');
const fs = require('node:fs');
const helpers = require('../spec/helpers');
const cordova = require('../src/cordova/cordova');

Expand All @@ -44,7 +44,7 @@ describe('end-to-end plugin dependency tests', function () {

afterAll(function () {
process.chdir(__dirname); // Needed to rm the dir on Windows.
fs.removeSync(preparedProject);
fs.rmSync(preparedProject, { recursive: true, force: true });
});

let tmpDir, project, pluginsDir;
Expand All @@ -53,14 +53,14 @@ describe('end-to-end plugin dependency tests', function () {
project = path.join(tmpDir, 'project');
pluginsDir = path.join(project, 'plugins');

fs.copySync(preparedProject, project);
fs.cpSync(preparedProject, project, { recursive: true });
process.chdir(project);
delete process.env.PWD;
});

afterEach(function () {
process.chdir(__dirname); // Needed to rm the dir on Windows.
fs.removeSync(tmpDir);
fs.rmSync(tmpDir, { recursive: true, force: true });
});

it('Test 029 : should fail if dependency already installed is wrong version', function () {
Expand Down
16 changes: 8 additions & 8 deletions integration-tests/pkgJson.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
under the License.
*/

const path = require('path');
const fs = require('fs-extra');
const path = require('node:path');
const fs = require('node:fs');
const semver = require('semver');
const { listPlatforms, requireNoCache } = require('../src/cordova/util');
const { tmpDir: getTmpDir, testPlatform, getFixture, setDefaultTimeout } = require('../spec/helpers');
Expand All @@ -44,14 +44,14 @@ describe('pkgJson', function () {

afterEach(() => {
process.chdir(__dirname); // Needed to rm the dir on Windows.
fs.removeSync(tmpDir);
fs.rmSync(tmpDir, { recursive: true, force: true });
});

// Copies a fixture to temp dir to avoid modifiying it as they get installed as symlinks
function copyFixture (fixtureRelativePath) {
const fixturePath = path.join(fixturesPath, fixtureRelativePath);
const tmpPath = path.join(tmpDir, path.basename(fixtureRelativePath));
fs.copySync(fixturePath, tmpPath);
fs.cpSync(fixturePath, tmpPath, { recursive: true });
return tmpPath;
}

Expand All @@ -69,7 +69,7 @@ describe('pkgJson', function () {
function pluginVersion (pluginName) {
const p = path.join(project, 'plugins', pluginName, 'package.json');
expect(p).toExist();
return fs.readJsonSync(p).version;
return JSON.parse(fs.readFileSync(p)).version;
}

function specSatisfiedBy (version) {
Expand Down Expand Up @@ -125,11 +125,11 @@ describe('pkgJson', function () {

afterAll(() => {
process.chdir(__dirname); // Needed to rm the dir on Windows.
fs.removeSync(projectFixture);
fs.rmSync(projectFixture, { recursive: true, force: true });
});

beforeEach(function () {
fs.copySync(projectFixture, project);
fs.cpSync(projectFixture, project, { recursive: true });
process.chdir(project);
});

Expand Down Expand Up @@ -260,7 +260,7 @@ describe('pkgJson', function () {
}).then(function () {
return cordova.plugin('add', PLUGIN, { save: true });
}).then(function () {
const iosJson = fs.readJsonSync(path.join(project, 'platforms/ios/ios.json'));
const iosJson = JSON.parse(fs.readFileSync(path.join(project, 'platforms/ios/ios.json')));
expect(iosJson.installed_plugins[PLUGIN]).toBeDefined();

// Check that installed version satisfies the dependency spec
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/platform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
under the License.
*/

const path = require('path');
const fs = require('fs-extra');
const path = require('node:path');
const fs = require('node:fs');
const rewire = require('rewire');

const { tmpDir: getTmpDir, testPlatform, setDefaultTimeout } = require('../spec/helpers');
Expand All @@ -41,13 +41,13 @@ describe('cordova/platform end-to-end', () => {
nodeModulesDir = path.join(project, 'node_modules');
testPlatformDir = path.join(platformsDir, testPlatform);

fs.copySync(path.join(fixturesDir, 'basePkgJson'), project);
fs.cpSync(path.join(fixturesDir, 'basePkgJson'), project, { recursive: true });
process.chdir(project);
});

afterEach(() => {
process.chdir(__dirname); // Needed to rm the dir on Windows.
fs.removeSync(tmpDir);
fs.rmSync(tmpDir, { recursive: true, force: true });
});

function installedPlatforms () {
Expand Down
14 changes: 7 additions & 7 deletions integration-tests/plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
under the License.
*/

const fs = require('fs-extra');
const fs = require('node:fs');
const path = require('node:path');
const helpers = require('../spec/helpers');
const path = require('path');
const events = require('cordova-common').events;
const cordova = require('../src/cordova/cordova');
const platforms = require('../src/platforms/platforms');
Expand Down Expand Up @@ -90,7 +90,7 @@ function mockPluginFetch (project, id, dir) {
spyOn(plugman, 'fetch').and.callFake(function (target, pluginPath, fetchOptions) {
const dest = path.join(project, 'plugins', id);

fs.copySync(path.join(dir, 'plugin.xml'), path.join(dest, 'plugin.xml'));
fs.cpSync(path.join(dir, 'plugin.xml'), path.join(dest, 'plugin.xml'));
return Promise.resolve(dest);
});
}
Expand All @@ -107,7 +107,7 @@ describe('plugin end-to-end', function () {
beforeEach(function () {
project = path.join(tmpDir, `project-${Date.now()}`);
// Reset our test project and change into it
fs.copySync(preparedProject, project);
fs.cpSync(preparedProject, project, { recursive: true });
process.chdir(project);

// Reset origCwd before each spec to respect chdirs
Expand All @@ -120,7 +120,7 @@ describe('plugin end-to-end', function () {

afterEach(function () {
process.chdir(path.join(__dirname, '..')); // Needed to rm the dir on Windows.
fs.removeSync(project);
fs.rmSync(project, { recursive: true, force: true });
});

it('Test 001 : should successfully add and remove a plugin with no options', function () {
Expand All @@ -138,11 +138,11 @@ describe('plugin end-to-end', function () {
// Copy plugin to subdir inside of the project. This is required since path.relative
// returns an absolute path when source and dest are on different drives
const plugindir = path.join(project, 'custom-plugins/some-plugin-inside-subfolder');
fs.copySync(path.join(pluginsDir, 'fake1'), plugindir);
fs.cpSync(path.join(pluginsDir, 'fake1'), plugindir, { recursive: true });

// Create a subdir, where we're going to run cordova from
const subdir = path.join(project, 'bin');
fs.ensureDirSync(subdir);
fs.mkdirSync(subdir, { recursive: true });
process.chdir(subdir);

// Add plugin using relative path
Expand Down
29 changes: 15 additions & 14 deletions integration-tests/plugman_fetch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
specific language governing permissions and limitations
under the License.
*/

const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const rewire = require('rewire');
const fetch = rewire('../src/plugman/fetch');
const fs = require('fs-extra');
const os = require('os');
const path = require('path');
const metadata = require('../src/plugman/util/metadata');
const temp = path.join(os.tmpdir(), 'plugman', 'fetch');
const plugins_dir = path.join(__dirname, '..', 'spec', 'plugman', 'plugins');
Expand All @@ -36,11 +37,11 @@ describe('fetch', function () {
let sym;

beforeEach(function () {
fs.removeSync(temp);
fs.rmSync(temp, { recursive: true, force: true });

spyOn(fs, 'removeSync');
spyOn(fs, 'rmSync');
sym = spyOn(fs, 'symlinkSync');
spyOn(fs, 'copySync').and.callThrough();
spyOn(fs, 'cpSync').and.callThrough();
spyOn(metadata, 'save_fetch_metadata');

const fetchSpy = jasmine.createSpy('fetch')
Expand All @@ -50,23 +51,23 @@ describe('fetch', function () {

it('Test 001 : should copy locally-available plugin to plugins directory', function () {
return fetch(test_plugin, temp).then(function () {
expect(fs.copySync).toHaveBeenCalledWith(test_plugin, path.join(temp, test_plugin_id), jasmine.objectContaining({ dereference: true }));
expect(fs.cpSync).toHaveBeenCalledWith(test_plugin, path.join(temp, test_plugin_id), jasmine.objectContaining({ dereference: true }));
});
});

it('Test 008 : should copy locally-available plugin to plugins directory when spaces in path', () => {
const testPluginWithSpace = path.join(temp, 'folder with space/org.test.plugins.childbrowser');
fs.copySync(test_plugin, testPluginWithSpace);
fs.copySync.calls.reset();
fs.cpSync(test_plugin, testPluginWithSpace, { recursive: true });
fs.cpSync.calls.reset();

return fetch(testPluginWithSpace, temp).then(() => {
expect(fs.copySync).toHaveBeenCalledWith(testPluginWithSpace, path.join(temp, test_plugin_id), jasmine.any(Object));
expect(fs.cpSync).toHaveBeenCalledWith(testPluginWithSpace, path.join(temp, test_plugin_id), jasmine.any(Object));
});
});

it('Test 002 : should copy locally-available plugin to plugins directory when adding a plugin with searchpath argument', function () {
return fetch(test_plugin_id, temp, { searchpath: test_plugin_searchpath }).then(function () {
expect(fs.copySync).toHaveBeenCalledWith(
expect(fs.cpSync).toHaveBeenCalledWith(
pathNormalizingTo(test_plugin),
path.join(temp, test_plugin_id),
jasmine.objectContaining({ dereference: true })
Expand Down Expand Up @@ -109,7 +110,7 @@ describe('fetch', function () {
});
it('Test 027 : should copy locally-available plugin to plugins directory', function () {
return fetch(test_pkgjson_plugin, temp).then(function () {
expect(fs.copySync).toHaveBeenCalledWith(test_pkgjson_plugin, path.join(temp, 'pkgjson-test-plugin'), jasmine.objectContaining({ dereference: true }));
expect(fs.cpSync).toHaveBeenCalledWith(test_pkgjson_plugin, path.join(temp, 'pkgjson-test-plugin'), jasmine.objectContaining({ dereference: true }));
expect(fetch.__get__('fetch')).toHaveBeenCalledTimes(1);
});
});
Expand All @@ -129,10 +130,10 @@ describe('fetch', function () {
});

it('Test 021 : should skip copy to avoid recursive error', function () {
spyOn(fs, 'copySync');
spyOn(fs, 'cpSync');

return fetch(srcDir, appDir).then(function () {
expect(fs.copySync).not.toHaveBeenCalled();
expect(fs.cpSync).not.toHaveBeenCalled();
});
});
});
Expand Down
Loading
Loading