Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
99c67da
chore(dev-dep): added @cordova/eslint-config at 6.0.1
erisu Apr 3, 2026
c39d767
chore(lint): apply lint auto-corrections
erisu Apr 3, 2026
b25f2cc
test(lint): PBXFile constructor name to start with uppercase
erisu Apr 3, 2026
d85ce66
test(lint): PBXProject constructor name to start with uppercase
erisu Apr 3, 2026
97dadef
test(lint): update more constructor name to start with uppercase
erisu Apr 3, 2026
aa59e3d
chore(lint): variable cleanup in test dir
erisu Apr 3, 2026
79de0b9
chore(lint): remove unused methods in test dir
erisu Apr 3, 2026
bc2ad5f
chore(lint): use path.join instead of string concatenation
erisu Apr 3, 2026
28d907c
chore(lint): inline disable no-template-curly-in-string
erisu Apr 3, 2026
985211a
chore(lint): remove unnecessary read for buildPhase after addBuildPhase
erisu Apr 3, 2026
54ed1a7
chore(lint): remove unnecessary variable
erisu Apr 3, 2026
bb4aee7
chore(lint): resolve no-prototype-builtins
erisu Apr 3, 2026
ce795f2
chore(lint): resolve eqeqeq & spacing
erisu Apr 3, 2026
c6901ab
chore(lint): resolve eqeqeq & unused variables in lib/pbxWriter
erisu Apr 3, 2026
a021547
chore(lint): resolve lint errors in lib/pbxFile
erisu Apr 3, 2026
aae2077
chore(lint): uppercase PBXProject in lib/pbxProject.js
erisu Apr 3, 2026
d0e9fd0
chore(lint): uppercase PBXFile & PBXWriter in lib/pbxProject.js
erisu Apr 3, 2026
cfc34cc
chore(lint): resolve eqeqeq in lib/pbxProject.js
erisu Apr 3, 2026
80a43fe
chore(lint): cleanup loops in lib/pbxProject.js
erisu Apr 3, 2026
9726833
chore(lint): resolve no-unused-vars in lib/pbxProject.js
erisu Apr 3, 2026
fd61320
chore(lint): resolve no-var in lib/pbxProject.js
erisu Apr 3, 2026
b4c3846
chore(lint): resolve no-undef in lib/pbxProject.js
erisu Apr 3, 2026
62504f3
chore(lint): resolve no-new-object in lib/pbxProject.js
erisu Apr 3, 2026
cdfbc78
chore(lint): use path.join instead of string concatenation in lib/pbx…
erisu Apr 3, 2026
52ce499
chore(lint): resolve no-mixed-operators in lib/pbxProject.js
erisu Apr 3, 2026
057e6f9
chore(lint): declare variable on own line
erisu Apr 8, 2026
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
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
.*
coverage
test
eslint.config.js
licence_checker.yml
33 changes: 33 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

const { defineConfig, globalIgnores } = require('eslint/config');
const nodeConfig = require('@cordova/eslint-config/node');
const nodeTestConfig = require('@cordova/eslint-config/node-tests');

module.exports = defineConfig([
globalIgnores([
'lib/parser/pbxproj.js'
]),
...nodeConfig,
...nodeTestConfig.map(config => ({
files: ['test/**/*.js'],
...config
}))
]);
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
under the License.
*/

exports.project = require('./lib/pbxProject')
exports.project = require('./lib/pbxProject');
9 changes: 5 additions & 4 deletions lib/parseJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

// parsing is slow and blocking right now
// so we do it in a separate process
var fs = require('fs'),
parser = require('./parser/pbxproj'),
path = process.argv[2],
fileContents, obj;
const fs = require('fs');
const parser = require('./parser/pbxproj');
const path = process.argv[2];
let fileContents;
let obj;

try {
fileContents = fs.readFileSync(path, 'utf-8');
Expand Down
212 changes: 97 additions & 115 deletions lib/pbxFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,80 +17,77 @@
under the License.
*/

var path = require('path'),
util = require('util');

var DEFAULT_SOURCETREE = '"<group>"',
DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR',
DEFAULT_FILEENCODING = 4,
DEFAULT_GROUP = 'Resources',
DEFAULT_FILETYPE = 'unknown';

var FILETYPE_BY_EXTENSION = {
a: 'archive.ar',
app: 'wrapper.application',
appex: 'wrapper.app-extension',
bundle: 'wrapper.plug-in',
dylib: 'compiled.mach-o.dylib',
framework: 'wrapper.framework',
h: 'sourcecode.c.h',
m: 'sourcecode.c.objc',
markdown: 'text',
mdimporter: 'wrapper.cfbundle',
octest: 'wrapper.cfbundle',
pch: 'sourcecode.c.h',
plist: 'text.plist.xml',
sh: 'text.script.sh',
swift: 'sourcecode.swift',
tbd: 'sourcecode.text-based-dylib-definition',
xcassets: 'folder.assetcatalog',
xcconfig: 'text.xcconfig',
xcdatamodel: 'wrapper.xcdatamodel',
xcodeproj: 'wrapper.pb-project',
xctest: 'wrapper.cfbundle',
xib: 'file.xib',
strings: 'text.plist.strings'
},
GROUP_BY_FILETYPE = {
'archive.ar': 'Frameworks',
'compiled.mach-o.dylib': 'Frameworks',
'sourcecode.text-based-dylib-definition': 'Frameworks',
'wrapper.framework': 'Frameworks',
'embedded.framework': 'Embed Frameworks',
'sourcecode.c.h': 'Resources',
'sourcecode.c.objc': 'Sources',
'sourcecode.swift': 'Sources'
},
PATH_BY_FILETYPE = {
'compiled.mach-o.dylib': 'usr/lib/',
'sourcecode.text-based-dylib-definition': 'usr/lib/',
'wrapper.framework': 'System/Library/Frameworks/'
},
SOURCETREE_BY_FILETYPE = {
'compiled.mach-o.dylib': 'SDKROOT',
'sourcecode.text-based-dylib-definition': 'SDKROOT',
'wrapper.framework': 'SDKROOT'
},
ENCODING_BY_FILETYPE = {
'sourcecode.c.h': 4,
'sourcecode.c.h': 4,
'sourcecode.c.objc': 4,
'sourcecode.swift': 4,
'text': 4,
'text.plist.xml': 4,
'text.script.sh': 4,
'text.xcconfig': 4,
'text.plist.strings': 4
};


function unquoted(text){
return text == null ? '' : text.replace (/(^")|("$)/g, '')
const path = require('path');
const util = require('util');

const DEFAULT_SOURCETREE = '"<group>"';
const DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR';
const DEFAULT_GROUP = 'Resources';
const DEFAULT_FILETYPE = 'unknown';

const FILETYPE_BY_EXTENSION = {
a: 'archive.ar',
app: 'wrapper.application',
appex: 'wrapper.app-extension',
bundle: 'wrapper.plug-in',
dylib: 'compiled.mach-o.dylib',
framework: 'wrapper.framework',
h: 'sourcecode.c.h',
m: 'sourcecode.c.objc',
markdown: 'text',
mdimporter: 'wrapper.cfbundle',
octest: 'wrapper.cfbundle',
pch: 'sourcecode.c.h',
plist: 'text.plist.xml',
sh: 'text.script.sh',
swift: 'sourcecode.swift',
tbd: 'sourcecode.text-based-dylib-definition',
xcassets: 'folder.assetcatalog',
xcconfig: 'text.xcconfig',
xcdatamodel: 'wrapper.xcdatamodel',
xcodeproj: 'wrapper.pb-project',
xctest: 'wrapper.cfbundle',
xib: 'file.xib',
strings: 'text.plist.strings'
};
const GROUP_BY_FILETYPE = {
'archive.ar': 'Frameworks',
'compiled.mach-o.dylib': 'Frameworks',
'sourcecode.text-based-dylib-definition': 'Frameworks',
'wrapper.framework': 'Frameworks',
'embedded.framework': 'Embed Frameworks',
'sourcecode.c.h': 'Resources',
'sourcecode.c.objc': 'Sources',
'sourcecode.swift': 'Sources'
};
const PATH_BY_FILETYPE = {
'compiled.mach-o.dylib': 'usr/lib/',
'sourcecode.text-based-dylib-definition': 'usr/lib/',
'wrapper.framework': 'System/Library/Frameworks/'
};
const SOURCETREE_BY_FILETYPE = {
'compiled.mach-o.dylib': 'SDKROOT',
'sourcecode.text-based-dylib-definition': 'SDKROOT',
'wrapper.framework': 'SDKROOT'
};
const ENCODING_BY_FILETYPE = {
'sourcecode.c.h': 4,
'sourcecode.c.objc': 4,
'sourcecode.swift': 4,
text: 4,
'text.plist.xml': 4,
'text.script.sh': 4,
'text.xcconfig': 4,
'text.plist.strings': 4
};

function unquoted (text) {
return text == null ? '' : text.replace(/(^")|("$)/g, '');
}

function detectType(filePath) {
var extension = path.extname(filePath).substring(1),
filetype = FILETYPE_BY_EXTENSION[unquoted(extension)];
function detectType (filePath) {
const extension = path.extname(filePath).substring(1);
const filetype = FILETYPE_BY_EXTENSION[unquoted(extension)];

if (!filetype) {
return DEFAULT_FILETYPE;
Expand All @@ -99,31 +96,31 @@ function detectType(filePath) {
return filetype;
}

function defaultExtension(fileRef) {
var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ?
fileRef.lastKnownFileType : fileRef.explicitFileType;
function defaultExtension (fileRef) {
const filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType !== DEFAULT_FILETYPE
? fileRef.lastKnownFileType
: fileRef.explicitFileType;

for(var extension in FILETYPE_BY_EXTENSION) {
if(FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension)) ) {
if(FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype) )
return extension;
for (const extension in FILETYPE_BY_EXTENSION) {
if (Object.prototype.hasOwnProperty.call(FILETYPE_BY_EXTENSION, unquoted(extension))) {
if (FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype)) { return extension; }
}
}
}

function defaultEncoding(fileRef) {
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
encoding = ENCODING_BY_FILETYPE[unquoted(filetype)];
function defaultEncoding (fileRef) {
const filetype = fileRef.lastKnownFileType || fileRef.explicitFileType;
const encoding = ENCODING_BY_FILETYPE[unquoted(filetype)];

if (encoding) {
return encoding;
}
}

function detectGroup(fileRef, opt) {
var extension = path.extname(fileRef.basename).substring(1),
filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
groupName = GROUP_BY_FILETYPE[unquoted(filetype)];
function detectGroup (fileRef, opt) {
const extension = path.extname(fileRef.basename).substring(1);
const filetype = fileRef.lastKnownFileType || fileRef.explicitFileType;
const groupName = GROUP_BY_FILETYPE[unquoted(filetype)];

if (extension === 'xcdatamodeld') {
return 'Sources';
Expand All @@ -140,10 +137,9 @@ function detectGroup(fileRef, opt) {
return groupName;
}

function detectSourcetree(fileRef) {

var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)];
function detectSourcetree (fileRef) {
const filetype = fileRef.lastKnownFileType || fileRef.explicitFileType;
const sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)];

if (fileRef.explicitFileType) {
return DEFAULT_PRODUCT_SOURCETREE;
Expand All @@ -160,9 +156,9 @@ function detectSourcetree(fileRef) {
return sourcetree;
}

function defaultPath(fileRef, filePath) {
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
defaultPath = PATH_BY_FILETYPE[unquoted(filetype)];
function defaultPath (fileRef, filePath) {
const filetype = fileRef.lastKnownFileType || fileRef.explicitFileType;
const defaultPath = PATH_BY_FILETYPE[unquoted(filetype)];

if (fileRef.customFramework) {
return filePath;
Expand All @@ -175,25 +171,15 @@ function defaultPath(fileRef, filePath) {
return filePath;
}

function defaultGroup(fileRef) {
var groupName = GROUP_BY_FILETYPE[fileRef.lastKnownFileType];

if (!groupName) {
return DEFAULT_GROUP;
}

return defaultGroup;
}

function pbxFile(filepath, opt) {
var opt = opt || {};
function pbxFile (filepath, opt) {
opt = opt || {};

this.basename = path.basename(filepath);
this.lastKnownFileType = opt.lastKnownFileType || detectType(filepath);
this.group = detectGroup(this, opt);

// for custom frameworks
if (opt.customFramework == true) {
if (opt.customFramework === true) {
this.customFramework = true;
this.dirname = path.dirname(filepath).replace(/\\/g, '/');
}
Expand All @@ -214,21 +200,17 @@ function pbxFile(filepath, opt) {
this.sourceTree = opt.sourceTree || detectSourcetree(this);
this.includeInIndex = 0;

if (opt.weak && opt.weak === true)
this.settings = { ATTRIBUTES: ['Weak'] };
if (opt.weak && opt.weak === true) { this.settings = { ATTRIBUTES: ['Weak'] }; }

if (opt.compilerFlags) {
if (!this.settings)
this.settings = {};
if (!this.settings) { this.settings = {}; }
this.settings.COMPILER_FLAGS = util.format('"%s"', opt.compilerFlags);
}

if (opt.embed && opt.sign) {
if (!this.settings)
this.settings = {};
if (!this.settings.ATTRIBUTES)
this.settings.ATTRIBUTES = [];
this.settings.ATTRIBUTES.push('CodeSignOnCopy');
if (!this.settings) { this.settings = {}; }
if (!this.settings.ATTRIBUTES) { this.settings.ATTRIBUTES = []; }
this.settings.ATTRIBUTES.push('CodeSignOnCopy');
}
}

Expand Down
Loading
Loading