Skip to content

Commit

Permalink
chore(deps): Modernize some dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogue committed Mar 25, 2024
1 parent 1974dbb commit 0354339
Show file tree
Hide file tree
Showing 28 changed files with 508 additions and 535 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
os: [macos-14]

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 Down Expand Up @@ -61,10 +61,10 @@ jobs:
os: [ubuntu-latest, windows-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 Down
11 changes: 5 additions & 6 deletions lib/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

const VERSION = require('../package.json').version;

const fs = require('fs-extra');
const path = require('path');
const unorm = require('unorm');
const fs = require('node:fs');
const path = require('node:path');
const util = require('node:util');
const projectFile = require('./projectFile');
const check_reqs = require('./check_reqs');
const {
Expand All @@ -33,7 +33,6 @@ const {
events,
PluginManager
} = require('cordova-common');
const util = require('util');

function setupEvents (externalEventEmitter) {
if (externalEventEmitter) {
Expand Down Expand Up @@ -111,7 +110,7 @@ class Api {
www: path.join(this.root, 'www'),
platformWww: path.join(this.root, 'platform_www'),
configXml: path.join(xcodeCordovaProj, 'config.xml'),
defaultConfigXml: path.join(this.root, 'cordova/defaults.xml'),
defaultConfigXml: path.join(this.root, 'cordova', 'defaults.xml'),
pbxproj: path.join(this.root, xcodeProjDir, 'project.pbxproj'),
xcodeProjDir: path.join(this.root, xcodeProjDir),
xcodeCordovaProj
Expand Down Expand Up @@ -142,7 +141,7 @@ class Api {
// CB-6992 it is necessary to normalize characters
// because node and shell scripts handles unicode symbols differently
// We need to normalize the name to NFD form since iOS uses NFD unicode form
const name = unorm.nfd(config.name());
const name = config.name().normalize('NFD');
let result;
try {
result = require('./create')
Expand Down
2 changes: 1 addition & 1 deletion lib/BridgingHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
'use strict';

const fs = require('fs-extra');
const fs = require('node:fs');
const CordovaError = require('cordova-common').CordovaError;

function BridgingHeader (bridgingHeaderPath) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Podfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
'use strict';

const fs = require('fs-extra');
const path = require('path');
const util = require('util');
const fs = require('node:fs');
const path = require('node:path');
const util = require('node:util');
const execa = require('execa');
const { CordovaError, events } = require('cordova-common');

Expand Down
6 changes: 3 additions & 3 deletions lib/PodsJson.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 path = require('path');
const util = require('util');
const fs = require('node:fs');
const path = require('node:path');
const util = require('node:util');
const xcode = require('xcode');
const check_reqs = require('./check_reqs');
const events = require('cordova-common').events;
Expand Down
13 changes: 7 additions & 6 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
* under the License.
*/

const path = require('path');
const fs = require('node:fs');
const fsp = require('node:fs/promises');
const path = require('node:path');
const util = require('node:util');
const which = require('which');
const execa = require('execa');
const { CordovaError, events } = require('cordova-common');
const fs = require('fs-extra');
const plist = require('plist');
const util = require('util');

const check_reqs = require('./check_reqs');
const projectFile = require('./projectFile');
Expand Down Expand Up @@ -206,7 +207,7 @@ module.exports.run = function (buildOpts) {
writeCodeSignStyle('Automatic');
}

return fs.writeFile(path.join(projectPath, 'cordova/build-extras.xcconfig'), extraConfig, 'utf-8');
return fsp.writeFile(path.join(projectPath, 'cordova', 'build-extras.xcconfig'), extraConfig, 'utf-8');
}).then(() => {
const configuration = buildOpts.release ? 'Release' : 'Debug';

Expand All @@ -218,7 +219,7 @@ module.exports.run = function (buildOpts) {
const buildOutputDir = path.join(projectPath, 'build', `${configuration}-${(buildOpts.device ? 'iphoneos' : 'iphonesimulator')}`);

// remove the build output folder before building
fs.removeSync(buildOutputDir);
fs.rmSync(buildOutputDir, { recursive: true, force: true });

const xcodebuildArgs = getXcodeBuildArgs(projectName, projectPath, configuration, emulatorTarget, buildOpts);
return execa('xcodebuild', xcodebuildArgs, { cwd: projectPath, stdio: 'inherit' });
Expand Down Expand Up @@ -278,7 +279,7 @@ module.exports.run = function (buildOpts) {
return execa('xcodebuild', xcodearchiveArgs, { cwd: projectPath, stdio: 'inherit' });
}

return fs.writeFile(exportOptionsPath, exportOptionsPlist, 'utf-8')
return fsp.writeFile(exportOptionsPath, exportOptionsPlist, 'utf-8')
.then(checkSystemRuby)
.then(packageArchive);
})
Expand Down
6 changes: 3 additions & 3 deletions lib/clean.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 execa = require('execa');
const { CordovaError } = require('cordova-common');

Expand All @@ -40,5 +40,5 @@ module.exports.run = function () {

return xcodebuildClean('Debug')
.then(() => xcodebuildClean('Release'))
.then(() => fs.removeSync(path.join(projectPath, 'build')));
.then(() => fs.rmSync(path.join(projectPath, 'build'), { recursive: true, force: true }));
};
74 changes: 37 additions & 37 deletions lib/create.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 xmlescape = require('xml-escape');
const { CordovaError, events } = require('cordova-common');
const pkg = require('../package');
Expand Down Expand Up @@ -55,7 +55,7 @@ exports.createProject = async (project_path, package_name, project_name, opts) =
id: package_name
},
options: {
templatePath: opts.customTemplate || path.join(ROOT, 'templates/project'),
templatePath: opts.customTemplate || path.join(ROOT, 'templates', 'project'),
linkLib: !!opts.link
}
}).create();
Expand All @@ -77,18 +77,18 @@ class ProjectCreator {
}

provideProjectTemplate () {
fs.copySync(this.options.templatePath, this.project.path);
fs.cpSync(this.options.templatePath, this.project.path, { recursive: true });

// TODO: why two .gitignores?
const r = this.projectPath('__PROJECT_NAME__');
fs.moveSync(path.join(r, 'gitignore'), path.join(r, '.gitignore'));
fs.copySync(path.join(r, '.gitignore'), this.projectPath('.gitignore'));
fs.renameSync(path.join(r, 'gitignore'), path.join(r, '.gitignore'));
fs.cpSync(path.join(r, '.gitignore'), this.projectPath('.gitignore'));
}

provideCordovaJs () {
fs.copySync(
this.projectPath('www/cordova.js'),
this.projectPath('platform_www/cordova.js')
fs.cpSync(
this.projectPath('www', 'cordova.js'),
this.projectPath('platform_www', 'cordova.js')
);
}

Expand All @@ -98,9 +98,9 @@ class ProjectCreator {
}

provideBuildScripts () {
const srcScriptsDir = path.join(ROOT, 'templates/cordova');
const srcScriptsDir = path.join(ROOT, 'templates', 'cordova');
const destScriptsDir = this.projectPath('cordova');
fs.copySync(srcScriptsDir, destScriptsDir);
fs.cpSync(srcScriptsDir, destScriptsDir, { recursive: true });
}

expandTokens () {
Expand All @@ -118,7 +118,7 @@ class ProjectCreator {
// like it should).
fs.symlinkSync(cordovaLibPathSrc, cordovaLibPathDest);
} else {
fs.copySync(cordovaLibPathSrc, cordovaLibPathDest);
fs.cpSync(cordovaLibPathSrc, cordovaLibPathDest, { recursive: true });
}
}

Expand All @@ -137,7 +137,7 @@ class ProjectCreator {
}

// Replace magic line in project.pbxproj
const pbxprojPath = this.projectPath('__PROJECT_NAME__.xcodeproj/project.pbxproj');
const pbxprojPath = this.projectPath('__PROJECT_NAME__.xcodeproj', 'project.pbxproj');
transformFileContents(pbxprojPath, contents => {
const regex = /(.+CordovaLib.xcodeproj.+PBXFileReference.+wrapper.pb-project.+)(path = .+?;)(.*)(sourceTree.+;)(.+)/;
const line = contents.split(/\r?\n/)
Expand All @@ -162,47 +162,47 @@ class ProjectCreator {
expandTokensInFileContents () {
// Expand __PROJECT_ID__ token in file contents
transformFileContents(
this.projectPath('__PROJECT_NAME__.xcodeproj/project.pbxproj'),
this.projectPath('__PROJECT_NAME__.xcodeproj', 'project.pbxproj'),
contents => contents.replace(/__PROJECT_ID__/g, this.project.id)
);

// Expand __PROJECT_NAME__ token in file contents
for (const p of [
'cordova/build-debug.xcconfig',
'cordova/build-release.xcconfig',
'__PROJECT_NAME__.xcworkspace/contents.xcworkspacedata',
'__PROJECT_NAME__.xcworkspace/xcshareddata/xcschemes/__PROJECT_NAME__.xcscheme',
'__PROJECT_NAME__.xcodeproj/project.pbxproj',
'__PROJECT_NAME__/AppDelegate.h',
'__PROJECT_NAME__/AppDelegate.m',
'__PROJECT_NAME__/MainViewController.h',
'__PROJECT_NAME__/MainViewController.m',
'__PROJECT_NAME__/main.m',
'__PROJECT_NAME__/__PROJECT_NAME__-Info.plist',
'__PROJECT_NAME__/__PROJECT_NAME__-Prefix.pch'
['cordova', 'build-debug.xcconfig'],
['cordova', 'build-release.xcconfig'],
['__PROJECT_NAME__.xcworkspace', 'contents.xcworkspacedata'],
['__PROJECT_NAME__.xcworkspace', 'xcshareddata', 'xcschemes', '__PROJECT_NAME__.xcscheme'],
['__PROJECT_NAME__.xcodeproj', 'project.pbxproj'],
['__PROJECT_NAME__', 'AppDelegate.h'],
['__PROJECT_NAME__', 'AppDelegate.m'],
['__PROJECT_NAME__', 'MainViewController.h'],
['__PROJECT_NAME__', 'MainViewController.m'],
['__PROJECT_NAME__', 'main.m'],
['__PROJECT_NAME__', '__PROJECT_NAME__-Info.plist'],
['__PROJECT_NAME__', '__PROJECT_NAME__-Prefix.pch']
]) {
this.expandProjectNameInFileContents(this.projectPath(p));
this.expandProjectNameInFileContents(this.projectPath(...p));
}
}

expandTokensInFileNames () {
// Expand __PROJECT_NAME__ token in file & folder names
for (const p of [
'__PROJECT_NAME__.xcworkspace/xcshareddata/xcschemes/__PROJECT_NAME__.xcscheme',
'__PROJECT_NAME__.xcworkspace',
'__PROJECT_NAME__.xcodeproj',
'__PROJECT_NAME__/__PROJECT_NAME__-Info.plist',
'__PROJECT_NAME__/__PROJECT_NAME__-Prefix.pch',
'__PROJECT_NAME__'
['__PROJECT_NAME__.xcworkspace', 'xcshareddata', 'xcschemes', '__PROJECT_NAME__.xcscheme'],
['__PROJECT_NAME__.xcworkspace'],
['__PROJECT_NAME__.xcodeproj'],
['__PROJECT_NAME__', '__PROJECT_NAME__-Info.plist'],
['__PROJECT_NAME__', '__PROJECT_NAME__-Prefix.pch'],
['__PROJECT_NAME__']
]) {
this.expandProjectNameInBaseName(this.projectPath(p));
this.expandProjectNameInBaseName(this.projectPath(...p));
}
}

expandProjectNameInBaseName (f) {
const { dir, base } = path.parse(f);
const newBase = base.replace('__PROJECT_NAME__', this.project.name);
return fs.moveSync(f, path.join(dir, newBase));
return fs.renameSync(f, path.join(dir, newBase));
}

expandProjectNameInFileContents (f) {
Expand All @@ -217,8 +217,8 @@ class ProjectCreator {
);
}

projectPath (projectRelativePath) {
return path.join(this.project.path, projectRelativePath);
projectPath (...projectRelativePaths) {
return path.join(this.project.path, ...projectRelativePaths);
}
}

Expand Down
Loading

0 comments on commit 0354339

Please sign in to comment.