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

breaking: add & use fs-extra w/ fixes #847

Merged
merged 2 commits into from
May 20, 2020
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
2 changes: 1 addition & 1 deletion bin/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
const shell = require('shelljs');
const Q = require('q');
const path = require('path');
const fs = require('fs');
const fs = require('fs-extra');
const xmlescape = require('xml-escape');
const ROOT = path.join(__dirname, '..', '..');
const events = require('cordova-common').events;
Expand Down
2 changes: 1 addition & 1 deletion bin/templates/scripts/cordova/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// Coho updates this line
const VERSION = '6.0.0-dev';

const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');
const unorm = require('unorm');
const projectFile = require('./lib/projectFile');
Expand Down
2 changes: 1 addition & 1 deletion bin/templates/scripts/cordova/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');
const fs = require('fs-extra');
const CordovaError = require('cordova-common').CordovaError;

function BridgingHeader (bridgingHeaderPath) {
Expand Down
2 changes: 1 addition & 1 deletion bin/templates/scripts/cordova/lib/Podfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
'use strict';

const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');
const util = require('util');
const events = require('cordova-common').events;
Expand Down
2 changes: 1 addition & 1 deletion bin/templates/scripts/cordova/lib/PodsJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
under the License.
*/

const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');
const util = require('util');
const events = require('cordova-common').events;
Expand Down
2 changes: 1 addition & 1 deletion bin/templates/scripts/cordova/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Q = require('q');
const path = require('path');
const shell = require('shelljs');
const superspawn = require('cordova-common').superspawn;
const fs = require('fs');
const fs = require('fs-extra');
const plist = require('plist');
const util = require('util');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
under the License.
*/
'use strict';
const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');
const shell = require('shelljs');
const util = require('util');
Expand Down
2 changes: 1 addition & 1 deletion bin/templates/scripts/cordova/lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

'use strict';
const Q = require('q');
const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');
const shell = require('shelljs');
const unorm = require('unorm');
Expand Down
2 changes: 1 addition & 1 deletion bin/templates/scripts/cordova/lib/projectFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const xcode = require('xcode');
const plist = require('plist');
const _ = require('underscore');
const path = require('path');
const fs = require('fs');
const fs = require('fs-extra');
const shell = require('shelljs');

const pluginHandlers = require('./plugman/pluginHandlers');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
},
"dependencies": {
"cordova-common": "^4.0.1",
"fs-extra": "^9.0.0",
"ios-sim": "^9.0.0",
"nopt": "^4.0.3",
"plist": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/unit/Api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

const path = require('path');
const fs = require('fs');
const fs = require('fs-extra');
const EventEmitter = require('events');
const PluginManager = require('cordova-common').PluginManager;
const Api = require('../../../bin/templates/scripts/cordova/Api');
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/unit/BridgingHeader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
under the License.
*/

const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');

const BridgingHeader = require(path.resolve(path.join(__dirname, '..', '..', '..', 'bin', 'templates', 'scripts', 'cordova', 'lib', 'BridgingHeader.js'))).BridgingHeader;
Expand Down
10 changes: 5 additions & 5 deletions tests/spec/unit/Plugman/common.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');
const osenv = require('os');
const shell = require('shelljs');
Expand Down Expand Up @@ -129,14 +129,14 @@ describe('common handler routines', () => {
});

describe('deleteJava', () => {
it('Test 009 : should call fs.unlinkSync on the provided paths', () => {
// This is testing that shelljs.rm is removing the source file.
it('Test 009 : source file should have been removed', () => {
shell.mkdir('-p', srcDirTree);
fs.writeFileSync(srcFile, 'contents', 'utf-8');

const s = spyOn(fs, 'unlinkSync').and.callThrough();
expect(fs.existsSync(srcFile)).toBe(true);
removeFileAndParents(project_dir, srcFile);
expect(s).toHaveBeenCalled();
expect(s).toHaveBeenCalledWith(path.resolve(project_dir, srcFile));
expect(fs.existsSync(srcFile)).toBe(false);

shell.rm('-rf', srcDirTree);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/unit/Plugman/pluginHandler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

const os = require('os');
const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');
const rewire = require('rewire');
const shell = require('shelljs');
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/unit/Podfile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

const path = require('path');
const util = require('util');
const fs = require('fs');
const fs = require('fs-extra');
const CordovaError = require('cordova-common').CordovaError;

const PROJECT_NAME = 'testProj';
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/unit/PodsJson.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
under the License.
*/

const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');
const util = require('util');
const CordovaError = require('cordova-common').CordovaError;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<widget id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SampleApp</name>
<access origin="*" allows-arbitrary-loads-for-media="false" />
</widget>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<widget id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SampleApp</name>
<access origin="*" allows-arbitrary-loads-for-media="true" />
</widget>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<widget id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SampleApp</name>
<access origin="*" allows-arbitrary-loads-in-media="false" />
</widget>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<widget id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SampleApp</name>
<access origin="*" allows-arbitrary-loads-in-media="true" />
</widget>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<widget id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SampleApp</name>
<access origin="*" allows-arbitrary-loads-in-web-content="true" />
</widget>
24 changes: 24 additions & 0 deletions tests/spec/unit/fixtures/prepare/allows-local-networking-true.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<widget id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SampleApp</name>
<access origin="*" allows-local-networking="true" />
</widget>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<widget id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SampleApp</name>
<access origin="http://cordova.apache.org" allows-arbitrary-loads-in-web-content="true" allows-arbitrary-loads-in-media="true" allows-local-networking="true" />
</widget>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<widget id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SampleApp</name>
<allow-navigation href="http://cordova.apache.org" allows-arbitrary-loads-in-web-content="true" allows-arbitrary-loads-in-media="true" allows-local-networking="true" />
</widget>
24 changes: 24 additions & 0 deletions tests/spec/unit/fixtures/prepare/wildcard-navigation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<widget id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SampleApp</name>
<allow-navigation href="*" />
</widget>
Loading