Skip to content

Commit b258ad9

Browse files
committed
feat(spm): Move CordovaPlugins into the packages dir
This helps keep the top level project directory a bit cleaner by hiding our CordovaPlugins SPM accumulator package inside the packages directory.
1 parent 94ef873 commit b258ad9

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

lib/SwiftPackage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const CordovaError = require('cordova-common').CordovaError;
2424
class SwiftPackage {
2525
constructor (projectRoot) {
2626
this.root = projectRoot;
27-
this.path = path.join(this.root, 'CordovaPlugins', 'Package.swift');
27+
this.path = path.join(this.root, 'packages', 'cordova-ios-plugins', 'Package.swift');
2828

2929
if (!fs.existsSync(this.path)) {
3030
throw new CordovaError('Package.swift is not found.');

templates/project/App.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,9 @@
529529
isa = XCLocalSwiftPackageReference;
530530
relativePath = "../../../cordova-ios";
531531
};
532-
90D82ABB2CF19AEA001383CF /* XCLocalSwiftPackageReference "CordovaPlugins" */ = {
532+
90D82ABB2CF19AEA001383CF /* XCLocalSwiftPackageReference "packages/cordova-ios-plugins" */ = {
533533
isa = XCLocalSwiftPackageReference;
534-
relativePath = CordovaPlugins;
534+
relativePath = "packages/cordova-ios-plugins";
535535
};
536536
/* End XCLocalSwiftPackageReference section */
537537

tests/spec/unit/SwiftPackage.spec.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ describe('SwiftPackage', () => {
5151

5252
let pkg;
5353
beforeEach(() => {
54-
fs.mkdirSync(path.join(tmpDir.name, 'CordovaPlugins'));
55-
fs.writeFileSync(path.join(tmpDir.name, 'CordovaPlugins', 'Package.swift'), fixturePackage, 'utf8');
54+
fs.mkdirSync(path.join(tmpDir.name, 'packages', 'cordova-ios-plugins'), { recursive: true });
55+
fs.writeFileSync(path.join(tmpDir.name, 'packages', 'cordova-ios-plugins', 'Package.swift'), fixturePackage, 'utf8');
5656

5757
pkg = new SwiftPackage(tmpDir.name);
5858
});
5959

6060
it('should add plugin references to the package file', () => {
6161
pkg.addPlugin(my_plugin);
6262

63-
const pkgPath = path.join(tmpDir.name, 'CordovaPlugins', 'Package.swift');
63+
const pkgPath = path.join(tmpDir.name, 'packages', 'cordova-ios-plugins', 'Package.swift');
6464
const content = fs.readFileSync(pkgPath, 'utf8');
65-
expect(content).toContain('.package(name: "my-plugin", path: "../packages/my-plugin")');
65+
expect(content).toContain('.package(name: "my-plugin", path: "../my-plugin")');
6666
expect(content).toContain('.product(name: "my-plugin", package: "my-plugin")');
6767
});
6868

@@ -75,11 +75,11 @@ describe('SwiftPackage', () => {
7575
it('should add plugin references to the package file when linked', () => {
7676
pkg.addPlugin(my_plugin, { link: true });
7777

78-
const pkgPath = path.join(tmpDir.name, 'CordovaPlugins', 'Package.swift');
78+
const pkgPath = path.join(tmpDir.name, 'packages', 'cordova-ios-plugins', 'Package.swift');
7979
const content = fs.readFileSync(pkgPath, 'utf8');
8080

8181
expect(content).toContain('.package(name: "my-plugin", path: "');
82-
expect(content).not.toContain('.package(name: "my-plugin", path: "../packages/my-plugin")');
82+
expect(content).not.toContain('.package(name: "my-plugin", path: "../my-plugin")');
8383
expect(content).toContain('.product(name: "my-plugin", package: "my-plugin")');
8484
});
8585

@@ -98,8 +98,8 @@ describe('SwiftPackage', () => {
9898

9999
let pkg;
100100
beforeEach(() => {
101-
fs.mkdirSync(path.join(tmpDir.name, 'CordovaPlugins'));
102-
const pkgPath = path.join(tmpDir.name, 'CordovaPlugins', 'Package.swift');
101+
fs.mkdirSync(path.join(tmpDir.name, 'packages', 'cordova-ios-plugins'), { recursive: true });
102+
const pkgPath = path.join(tmpDir.name, 'packages', 'cordova-ios-plugins', 'Package.swift');
103103
fs.writeFileSync(pkgPath, fixturePackage, 'utf8');
104104

105105
pkg = new SwiftPackage(tmpDir.name);
@@ -109,7 +109,9 @@ describe('SwiftPackage', () => {
109109
it('should remove plugin references to the package file', () => {
110110
pkg.removePlugin(my_plugin);
111111

112-
const content = fs.readFileSync(path.join(tmpDir.name, 'CordovaPlugins', 'Package.swift'), 'utf8');
112+
const pkgPath = path.join(tmpDir.name, 'packages', 'cordova-ios-plugins', 'Package.swift');
113+
const content = fs.readFileSync(pkgPath, 'utf8');
114+
113115
expect(content).not.toContain('.package(name: "my-plugin"');
114116
expect(content).not.toContain('.product(name: "my-plugin", package: "my-plugin")');
115117
});

0 commit comments

Comments
 (0)