Skip to content

Commit f7e2953

Browse files
authored
chore(deps): Modernize some dependencies (#1413)
1 parent 0dd2c85 commit f7e2953

29 files changed

+516
-547
lines changed

.eslintrc.yml

-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,3 @@ overrides:
2424

2525
- files: [cordova-js-src/**/*.js]
2626
extends: '@cordova/eslint-config/browser'
27-
28-
# TODO add this to @cordova/eslint-config/browser
29-
rules:
30-
no-var: 0

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
os: [macos-14]
3030

3131
steps:
32-
- uses: actions/checkout@v3
32+
- uses: actions/checkout@v4
3333

3434
- name: Use Node.js ${{ matrix.node-version }}
35-
uses: actions/setup-node@v3
35+
uses: actions/setup-node@v4
3636
with:
3737
node-version: ${{ matrix.node-version }}
3838

@@ -61,10 +61,10 @@ jobs:
6161
os: [ubuntu-latest, windows-latest]
6262

6363
steps:
64-
- uses: actions/checkout@v3
64+
- uses: actions/checkout@v4
6565

6666
- name: Use Node.js ${{ matrix.node-version }}
67-
uses: actions/setup-node@v3
67+
uses: actions/setup-node@v4
6868
with:
6969
node-version: ${{ matrix.node-version }}
7070

lib/Api.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

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

24-
const fs = require('fs-extra');
25-
const path = require('path');
26-
const unorm = require('unorm');
24+
const fs = require('node:fs');
25+
const path = require('node:path');
26+
const util = require('node:util');
2727
const projectFile = require('./projectFile');
2828
const check_reqs = require('./check_reqs');
2929
const {
@@ -33,7 +33,6 @@ const {
3333
events,
3434
PluginManager
3535
} = require('cordova-common');
36-
const util = require('util');
3736

3837
function setupEvents (externalEventEmitter) {
3938
if (externalEventEmitter) {
@@ -111,7 +110,7 @@ class Api {
111110
www: path.join(this.root, 'www'),
112111
platformWww: path.join(this.root, 'platform_www'),
113112
configXml: path.join(xcodeCordovaProj, 'config.xml'),
114-
defaultConfigXml: path.join(this.root, 'cordova/defaults.xml'),
113+
defaultConfigXml: path.join(this.root, 'cordova', 'defaults.xml'),
115114
pbxproj: path.join(this.root, xcodeProjDir, 'project.pbxproj'),
116115
xcodeProjDir: path.join(this.root, xcodeProjDir),
117116
xcodeCordovaProj
@@ -142,7 +141,7 @@ class Api {
142141
// CB-6992 it is necessary to normalize characters
143142
// because node and shell scripts handles unicode symbols differently
144143
// We need to normalize the name to NFD form since iOS uses NFD unicode form
145-
const name = unorm.nfd(config.name());
144+
const name = config.name().normalize('NFD');
146145
let result;
147146
try {
148147
result = require('./create')

lib/BridgingHeader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
'use strict';
2020

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

2424
function BridgingHeader (bridgingHeaderPath) {

lib/Podfile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
*/
1919
'use strict';
2020

21-
const fs = require('fs-extra');
22-
const path = require('path');
23-
const util = require('util');
21+
const fs = require('node:fs');
22+
const path = require('node:path');
23+
const util = require('node:util');
2424
const execa = require('execa');
2525
const { CordovaError, events } = require('cordova-common');
2626

lib/PodsJson.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
under the License.
1818
*/
1919

20-
const fs = require('fs-extra');
21-
const path = require('path');
22-
const util = require('util');
20+
const fs = require('node:fs');
21+
const path = require('node:path');
22+
const util = require('node:util');
2323
const xcode = require('xcode');
2424
const check_reqs = require('./check_reqs');
2525
const events = require('cordova-common').events;

lib/build.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
* under the License.
1818
*/
1919

20-
const path = require('path');
20+
const fs = require('node:fs');
21+
const fsp = require('node:fs/promises');
22+
const path = require('node:path');
23+
const util = require('node:util');
2124
const which = require('which');
2225
const execa = require('execa');
2326
const { CordovaError, events } = require('cordova-common');
24-
const fs = require('fs-extra');
2527
const plist = require('plist');
26-
const util = require('util');
2728

2829
const check_reqs = require('./check_reqs');
2930
const projectFile = require('./projectFile');
@@ -206,7 +207,7 @@ module.exports.run = function (buildOpts) {
206207
writeCodeSignStyle('Automatic');
207208
}
208209

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

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

220221
// remove the build output folder before building
221-
fs.removeSync(buildOutputDir);
222+
fs.rmSync(buildOutputDir, { recursive: true, force: true });
222223

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

281-
return fs.writeFile(exportOptionsPath, exportOptionsPlist, 'utf-8')
282+
return fsp.writeFile(exportOptionsPath, exportOptionsPlist, 'utf-8')
282283
.then(checkSystemRuby)
283284
.then(packageArchive);
284285
})

lib/clean.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* under the License.
1818
*/
1919

20-
const path = require('path');
21-
const fs = require('fs-extra');
20+
const path = require('node:path');
21+
const fs = require('node:fs');
2222
const execa = require('execa');
2323
const { CordovaError } = require('cordova-common');
2424

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

4141
return xcodebuildClean('Debug')
4242
.then(() => xcodebuildClean('Release'))
43-
.then(() => fs.removeSync(path.join(projectPath, 'build')));
43+
.then(() => fs.rmSync(path.join(projectPath, 'build'), { recursive: true, force: true }));
4444
};

lib/create.js

+37-37
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
under the License.
1818
*/
1919

20-
const path = require('path');
21-
const fs = require('fs-extra');
20+
const path = require('node:path');
21+
const fs = require('node:fs');
2222
const xmlescape = require('xml-escape');
2323
const { CordovaError, events } = require('cordova-common');
2424
const pkg = require('../package');
@@ -55,7 +55,7 @@ exports.createProject = async (project_path, package_name, project_name, opts) =
5555
id: package_name
5656
},
5757
options: {
58-
templatePath: opts.customTemplate || path.join(ROOT, 'templates/project'),
58+
templatePath: opts.customTemplate || path.join(ROOT, 'templates', 'project'),
5959
linkLib: !!opts.link
6060
}
6161
}).create();
@@ -77,18 +77,18 @@ class ProjectCreator {
7777
}
7878

7979
provideProjectTemplate () {
80-
fs.copySync(this.options.templatePath, this.project.path);
80+
fs.cpSync(this.options.templatePath, this.project.path, { recursive: true });
8181

8282
// TODO: why two .gitignores?
8383
const r = this.projectPath('__PROJECT_NAME__');
84-
fs.moveSync(path.join(r, 'gitignore'), path.join(r, '.gitignore'));
85-
fs.copySync(path.join(r, '.gitignore'), this.projectPath('.gitignore'));
84+
fs.renameSync(path.join(r, 'gitignore'), path.join(r, '.gitignore'));
85+
fs.cpSync(path.join(r, '.gitignore'), this.projectPath('.gitignore'));
8686
}
8787

8888
provideCordovaJs () {
89-
fs.copySync(
90-
this.projectPath('www/cordova.js'),
91-
this.projectPath('platform_www/cordova.js')
89+
fs.cpSync(
90+
this.projectPath('www', 'cordova.js'),
91+
this.projectPath('platform_www', 'cordova.js')
9292
);
9393
}
9494

@@ -98,9 +98,9 @@ class ProjectCreator {
9898
}
9999

100100
provideBuildScripts () {
101-
const srcScriptsDir = path.join(ROOT, 'templates/cordova');
101+
const srcScriptsDir = path.join(ROOT, 'templates', 'cordova');
102102
const destScriptsDir = this.projectPath('cordova');
103-
fs.copySync(srcScriptsDir, destScriptsDir);
103+
fs.cpSync(srcScriptsDir, destScriptsDir, { recursive: true });
104104
}
105105

106106
expandTokens () {
@@ -118,7 +118,7 @@ class ProjectCreator {
118118
// like it should).
119119
fs.symlinkSync(cordovaLibPathSrc, cordovaLibPathDest);
120120
} else {
121-
fs.copySync(cordovaLibPathSrc, cordovaLibPathDest);
121+
fs.cpSync(cordovaLibPathSrc, cordovaLibPathDest, { recursive: true });
122122
}
123123
}
124124

@@ -137,7 +137,7 @@ class ProjectCreator {
137137
}
138138

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

169169
// Expand __PROJECT_NAME__ token in file contents
170170
for (const p of [
171-
'cordova/build-debug.xcconfig',
172-
'cordova/build-release.xcconfig',
173-
'__PROJECT_NAME__.xcworkspace/contents.xcworkspacedata',
174-
'__PROJECT_NAME__.xcworkspace/xcshareddata/xcschemes/__PROJECT_NAME__.xcscheme',
175-
'__PROJECT_NAME__.xcodeproj/project.pbxproj',
176-
'__PROJECT_NAME__/AppDelegate.h',
177-
'__PROJECT_NAME__/AppDelegate.m',
178-
'__PROJECT_NAME__/MainViewController.h',
179-
'__PROJECT_NAME__/MainViewController.m',
180-
'__PROJECT_NAME__/main.m',
181-
'__PROJECT_NAME__/__PROJECT_NAME__-Info.plist',
182-
'__PROJECT_NAME__/__PROJECT_NAME__-Prefix.pch'
171+
['cordova', 'build-debug.xcconfig'],
172+
['cordova', 'build-release.xcconfig'],
173+
['__PROJECT_NAME__.xcworkspace', 'contents.xcworkspacedata'],
174+
['__PROJECT_NAME__.xcworkspace', 'xcshareddata', 'xcschemes', '__PROJECT_NAME__.xcscheme'],
175+
['__PROJECT_NAME__.xcodeproj', 'project.pbxproj'],
176+
['__PROJECT_NAME__', 'AppDelegate.h'],
177+
['__PROJECT_NAME__', 'AppDelegate.m'],
178+
['__PROJECT_NAME__', 'MainViewController.h'],
179+
['__PROJECT_NAME__', 'MainViewController.m'],
180+
['__PROJECT_NAME__', 'main.m'],
181+
['__PROJECT_NAME__', '__PROJECT_NAME__-Info.plist'],
182+
['__PROJECT_NAME__', '__PROJECT_NAME__-Prefix.pch']
183183
]) {
184-
this.expandProjectNameInFileContents(this.projectPath(p));
184+
this.expandProjectNameInFileContents(this.projectPath(...p));
185185
}
186186
}
187187

188188
expandTokensInFileNames () {
189189
// Expand __PROJECT_NAME__ token in file & folder names
190190
for (const p of [
191-
'__PROJECT_NAME__.xcworkspace/xcshareddata/xcschemes/__PROJECT_NAME__.xcscheme',
192-
'__PROJECT_NAME__.xcworkspace',
193-
'__PROJECT_NAME__.xcodeproj',
194-
'__PROJECT_NAME__/__PROJECT_NAME__-Info.plist',
195-
'__PROJECT_NAME__/__PROJECT_NAME__-Prefix.pch',
196-
'__PROJECT_NAME__'
191+
['__PROJECT_NAME__.xcworkspace', 'xcshareddata', 'xcschemes', '__PROJECT_NAME__.xcscheme'],
192+
['__PROJECT_NAME__.xcworkspace'],
193+
['__PROJECT_NAME__.xcodeproj'],
194+
['__PROJECT_NAME__', '__PROJECT_NAME__-Info.plist'],
195+
['__PROJECT_NAME__', '__PROJECT_NAME__-Prefix.pch'],
196+
['__PROJECT_NAME__']
197197
]) {
198-
this.expandProjectNameInBaseName(this.projectPath(p));
198+
this.expandProjectNameInBaseName(this.projectPath(...p));
199199
}
200200
}
201201

202202
expandProjectNameInBaseName (f) {
203203
const { dir, base } = path.parse(f);
204204
const newBase = base.replace('__PROJECT_NAME__', this.project.name);
205-
return fs.moveSync(f, path.join(dir, newBase));
205+
return fs.renameSync(f, path.join(dir, newBase));
206206
}
207207

208208
expandProjectNameInFileContents (f) {
@@ -217,8 +217,8 @@ class ProjectCreator {
217217
);
218218
}
219219

220-
projectPath (projectRelativePath) {
221-
return path.join(this.project.path, projectRelativePath);
220+
projectPath (...projectRelativePaths) {
221+
return path.join(this.project.path, ...projectRelativePaths);
222222
}
223223
}
224224

0 commit comments

Comments
 (0)